Skip to content

Commit 73d51eb

Browse files
amroamroamromikesamuel
authored andcommitted
test_in_node: fix handling of local path
URL rewritten with file:// protocol and absolute path
1 parent 9c2b519 commit 73d51eb

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

tests/test_in_node

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/env node
22

3-
var Path = require("path");
4-
var Url = require("url");
3+
var path = require('path');
54
var Browser = require('zombie');
65
var htmlToText = require('html-to-text');
76

@@ -39,11 +38,9 @@ function startBrowser() {
3938
console.log('>> Complete');
4039
process.exit(returnCode);
4140
return;
42-
}
43-
var url_obj = Url.parse(url);
44-
if (!url_obj.protocol) {
45-
url_obj.protocol = "file";
46-
url = Url.format(url_obj);
41+
} else if (!/^(?:https?|ftp):/.test(url)) {
42+
// rewrite local path as a file:// URL
43+
url = encodeURI('file://' + path.resolve(url).replace(/\\/g, '/'));
4744
}
4845

4946
// load page

0 commit comments

Comments
 (0)