Skip to content

Commit 7e26a31

Browse files
committed
Use HTTPS for editing core modules.
1 parent 5d013f0 commit 7e26a31

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212
Thanks, [Jacky Alciné](https://jacky.wtf), for the help!
1313
- Resolves symlinks in paths before editing a file.
1414
Shows correct paths when using the relative symlink trick in `node_modules` (`ln -s .. node_modules/root`) and using `gf` on `require("root/lib/foo")`.
15+
- Uses the HTTPS variant of <https://rawgit.com> to download Node core module source files.
16+
This previously used HTTP because my Vim v7's Netrw didn't seem to handle HTTPS URLs. If that's still the case for you, set `g:node_repository_url`:
17+
18+
```vim
19+
let node_repository_url = "http://raw.githack.com/nodejs/node"
20+
```
1521

1622
## 0.8.1 (Apr 15, 2014)
1723
- Updates the URL from which Node.vim downloads Node core module source files.

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,18 @@ autocmd User Node
8484
\ endif
8585
```
8686

87+
#### Viewing Node.js core modules
88+
Open Vim in the directory of a Node.js project and use `:Nedit` with the name of the core module:
89+
```vim
90+
:Nedit http
91+
```
92+
93+
This downloads a single file from the Node.js repository for your Node version through <https://rawgit.com>. If you'd like to change the base URL, set `g:node_repository_url`:
94+
95+
```vim
96+
let node_repository_url = "https://example.com/nodejs/node"
97+
```
98+
8799

88100
License
89101
-------

autoload/node/lib.vim

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ let s:RELPATH = '\v^\.\.?(/|$)'
33
let s:MODULE = '\v^(/|\.\.?(/|$))@!'
44

55
" Damn Netrw can't handle HTTPS at all. It's 2013! Insecure bastard!
6-
let s:CORE_URL_PREFIX = "http://rawgit.com/nodejs/node"
6+
let s:CORE_URL_PREFIX = "https://rawgit.com/nodejs/node"
77
let s:CORE_MODULES = ["_debugger", "_http_agent", "_http_client",
88
\ "_http_common", "_http_incoming", "_http_outgoing", "_http_server",
99
\ "_linklist", "_stream_duplex", "_stream_passthrough", "_stream_readable",
@@ -19,7 +19,8 @@ function! node#lib#find(name, from)
1919
let l:version = node#lib#version()
2020
let l:version = empty(l:version) ? "master" : "v" . l:version
2121
let l:dir = a:name == "node" ? "src" : "lib"
22-
return s:CORE_URL_PREFIX ."/". l:version ."/". l:dir ."/". a:name .".js"
22+
let l:url = get(g:, "node_repository_url", s:CORE_URL_PREFIX)
23+
return l:url ."/". l:version ."/". l:dir ."/". a:name .".js"
2324
endif
2425

2526
let l:path = s:resolve(s:absolutize(a:name, a:from))

test/autoload/lib_test.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ def find(name)
264264
it "must return URL for core module for current Node version" do
265265
set_node_version "0.13.37"
266266
$vim.edit File.join(@dir, "index.js")
267-
url = "http://rawgit.com/nodejs/node/v0.13.37/lib/assert.js"
267+
url = "https://rawgit.com/nodejs/node/v0.13.37/lib/assert.js"
268268
find("assert").must_equal url
269269
end
270270

@@ -273,14 +273,14 @@ def find(name)
273273
File.chmod 0755, File.join(@dir, "node")
274274
$vim.edit File.join(@dir, "index.js")
275275
$vim.command(%(let $PATH = "#@dir:" . $PATH))
276-
url = "http://rawgit.com/nodejs/node/master/lib/assert.js"
276+
url = "https://rawgit.com/nodejs/node/master/lib/assert.js"
277277
find("assert").must_equal url
278278
end
279279

280280
it "must return URL for node.js for current Node version" do
281281
set_node_version "0.13.37"
282282
$vim.edit File.join(@dir, "index.js")
283-
url = "http://rawgit.com/nodejs/node/v0.13.37/src/node.js"
283+
url = "https://rawgit.com/nodejs/node/v0.13.37/src/node.js"
284284
find("node").must_equal url
285285
end
286286

@@ -289,7 +289,7 @@ def find(name)
289289
File.chmod 0755, File.join(@dir, "node")
290290
$vim.edit File.join(@dir, "index.js")
291291
$vim.command(%(let $PATH = "#@dir:" . $PATH))
292-
url = "http://rawgit.com/nodejs/node/master/src/node.js"
292+
url = "https://rawgit.com/nodejs/node/master/src/node.js"
293293
find("node").must_equal url
294294
end
295295
end

0 commit comments

Comments
 (0)