1
0
Fork 0
mirror of https://github.com/futurepress/epub.js.git synced 2025-10-02 14:49:16 +02:00

Implement encoding and decoding spineItem href lookup

This commit is contained in:
Fred Chasen 2017-10-31 14:00:30 -07:00
parent 230fb63c0f
commit dec8beeda7

View file

@ -140,7 +140,7 @@ class Spine {
} else if(typeof target === "string") {
// Remove fragments
target = target.split("#")[0];
index = this.spineByHref[target];
index = this.spineByHref[target] || this.spineByHref[encodeURI(target)];
}
return this.spineItems[index] || null;
@ -157,7 +157,12 @@ class Spine {
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.spineById[section.idref] = index;
return index;