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:
parent
932d9232c0
commit
e77818826b
5 changed files with 131 additions and 6 deletions
|
@ -104,6 +104,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){
|
||||
|
@ -252,8 +253,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
|
||||
|
@ -268,6 +267,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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue