Skip to content

Commit

Permalink
test_in_node: fix handling of local path
Browse files Browse the repository at this point in the history
URL rewritten with file:// protocol and absolute path
  • Loading branch information
amroamroamro authored and mikesamuel committed Jan 26, 2017
1 parent 9c2b519 commit 73d51eb
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions tests/test_in_node
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env node

var Path = require("path");
var Url = require("url");
var path = require('path');
var Browser = require('zombie');
var htmlToText = require('html-to-text');

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

// load page
Expand Down

0 comments on commit 73d51eb

Please sign in to comment.