diff options
| author | Michael Williamson <mike@zwobble.org> | 2017-05-18 20:08:38 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2017-05-18 20:08:38 +0100 |
| commit | c2d5d7043644cbd3e0a8bfe3d9251cc5eca811d4 (patch) | |
| tree | 92bd77fd3448f52f1de28239a37e354cc63feb44 /lib/docx/uris.js | |
| parent | 1c007ffd3b0d736f99306d448341868e35eee187 (diff) | |
Avoid parsing URI when replacing fragment
Diffstat (limited to 'lib/docx/uris.js')
| -rw-r--r-- | lib/docx/uris.js | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/docx/uris.js b/lib/docx/uris.js index 0179e5b..89d5be1 100644 --- a/lib/docx/uris.js +++ b/lib/docx/uris.js @@ -1,4 +1,5 @@ exports.uriToZipEntryName = uriToZipEntryName; +exports.replaceFragment = replaceFragment; function uriToZipEntryName(base, uri) { if (uri.charAt(0) === "/") { @@ -9,3 +10,12 @@ function uriToZipEntryName(base, uri) { return base + "/" + uri; } } + + +function replaceFragment(uri, fragment) { + var hashIndex = uri.indexOf("#"); + if (hashIndex !== -1) { + uri = uri.substring(0, hashIndex); + } + return uri + "#" + fragment; +} |
