1
0
Fork 0
mirror of https://github.com/futurepress/epub.js.git synced 2025-10-05 15:32:55 +02:00

add basic dev, handle ../ in book path

This commit is contained in:
Fred Chasen 2013-07-18 19:19:41 -07:00
parent 932d9232c0
commit e77818826b
5 changed files with 131 additions and 6 deletions

View file

@ -112,6 +112,7 @@ EPUBJS.Book.prototype.open = function(bookPath, forceReload){
//-- Get a absolute URL from the book path
this.bookUrl = this.urlFrom(bookPath);
// console.log("saved", saved, !forceReload)
//-- Remove the previous settings and reload
if(saved && !forceReload){
@ -260,8 +261,6 @@ EPUBJS.Book.prototype.urlFrom = function(bookPath){
//-- Get URL orgin, try for native or combine
origin = location.origin || location.protocol + "//" + location.host;
// if(bookPath[bookPath.length - 1] != "/") bookPath += "/";
//-- 1. Check if url is absolute
@ -276,6 +275,12 @@ EPUBJS.Book.prototype.urlFrom = function(bookPath){
//-- 3. Or find full path to url and add that
if(!absolute && !fromRoot){
//-- go back
if(bookPath.slice(0, 3) == "../"){
return EPUBJS.core.resolveUrl(location.href, bookPath);
}
return origin + EPUBJS.core.folder(location.pathname) + bookPath;
}

2
build/epub.min.js vendored

File diff suppressed because one or more lines are too long