Skip to content

Commit a1ef5cb

Browse files
committed
Better handling of document uris.
1 parent 96945bb commit a1ef5cb

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
node_modules
2+
npm-debug.log

phantom-scrape.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,15 @@ page.open(url, function(status) {
1818
}
1919
page.injectJs("vendor/Readability.js");
2020
json(page.evaluate(function(url) {
21-
return new Readability(document.location.href, document).parse();
21+
var location = document.location;
22+
var uri = {
23+
spec: location.href,
24+
host: location.host,
25+
prePath: location.protocol + "//" + location.host, // TODO This is incomplete, needs username/password and port
26+
scheme: location.protocol.substr(0, location.protocol.indexOf(":")),
27+
pathBase: location.protocol + "//" + location.host + location.pathname.substr(0, location.pathname.lastIndexOf("/") + 1)
28+
};
29+
return new Readability(uri, document).parse();
2230
}, url));
2331
phantom.exit();
2432
});

0 commit comments

Comments
 (0)