mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-04 15:09:16 +02:00
Fix url to handle file links
This commit is contained in:
parent
d6eeb2a458
commit
265df07917
6 changed files with 130 additions and 37 deletions
29
test/core.js
29
test/core.js
|
@ -56,6 +56,35 @@ describe('Core', function() {
|
|||
assert.equal( resolved, "http://example.com/derf.html" );
|
||||
});
|
||||
|
||||
// Doesn't work with path.parse
|
||||
xit("should handle directory with a dot", function() {
|
||||
var a = "http://example.com/fred/chasen/index.epub/";
|
||||
|
||||
var url = new Url(a);
|
||||
assert.equal( url.directory, "/fred/chasen/index.epub/" );
|
||||
assert.equal( url.extension, "" );
|
||||
});
|
||||
|
||||
it("should handle file urls", function() {
|
||||
var url = new Url("file:///var/mobile/Containers/Data/Application/F47E4434-9B98-4654-93F1-702336B08EE6/Documents/books/moby-dick/derf.html");
|
||||
|
||||
assert.equal( url.href, "file:///var/mobile/Containers/Data/Application/F47E4434-9B98-4654-93F1-702336B08EE6/Documents/books/moby-dick/derf.html" );
|
||||
assert.equal( url.directory, "/var/mobile/Containers/Data/Application/F47E4434-9B98-4654-93F1-702336B08EE6/Documents/books/moby-dick/" );
|
||||
assert.equal( url.extension, "html" );
|
||||
assert.equal( url.filename, "derf.html" );
|
||||
assert.equal( url.origin, "file://" ); // origin should be blank
|
||||
assert.equal( url.protocol, "file:" );
|
||||
assert.equal( url.search, "" );
|
||||
});
|
||||
|
||||
it("should resolve with file urls", function() {
|
||||
var a = "file:///var/mobile/Containers/Data/Application/books/";
|
||||
var b = "derf.html";
|
||||
|
||||
var resolved = new Url(a).resolve(b);
|
||||
assert.equal( resolved, "file:///var/mobile/Containers/Data/Application/books/derf.html" );
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue