mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-03 14:59:18 +02:00
Implement encoding and decoding spineItem href lookup
This commit is contained in:
parent
230fb63c0f
commit
dec8beeda7
1 changed files with 6 additions and 1 deletions
|
@ -140,7 +140,7 @@ class Spine {
|
||||||
} else if(typeof target === "string") {
|
} else if(typeof target === "string") {
|
||||||
// Remove fragments
|
// Remove fragments
|
||||||
target = target.split("#")[0];
|
target = target.split("#")[0];
|
||||||
index = this.spineByHref[target];
|
index = this.spineByHref[target] || this.spineByHref[encodeURI(target)];
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.spineItems[index] || null;
|
return this.spineItems[index] || null;
|
||||||
|
@ -157,7 +157,12 @@ class Spine {
|
||||||
|
|
||||||
this.spineItems.push(section);
|
this.spineItems.push(section);
|
||||||
|
|
||||||
|
// Encode and Decode href lookups
|
||||||
|
// see pr for details: https://github.com/futurepress/epub.js/pull/358
|
||||||
|
this.spineByHref[decodeURI(section.href)] = index;
|
||||||
|
this.spineByHref[encodeURI(section.href)] = index;
|
||||||
this.spineByHref[section.href] = index;
|
this.spineByHref[section.href] = index;
|
||||||
|
|
||||||
this.spineById[section.idref] = index;
|
this.spineById[section.idref] = index;
|
||||||
|
|
||||||
return index;
|
return index;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue