diff options
| author | Michael Williamson <mike@zwobble.org> | 2017-05-18 20:12:25 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2017-05-18 20:12:25 +0100 |
| commit | d0b4eb76001049a23fe038025cfa56472703fa70 (patch) | |
| tree | ae48abeafbf170611e978d880447c5bb84d02e72 /mammoth/docx/uris.py | |
| parent | 85f99611c84cf0853200fb358f135160c063b690 (diff) | |
Avoid parsing URI when replacing fragment
Diffstat (limited to 'mammoth/docx/uris.py')
| -rw-r--r-- | mammoth/docx/uris.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/mammoth/docx/uris.py b/mammoth/docx/uris.py index 59f3ffe..892078e 100644 --- a/mammoth/docx/uris.py +++ b/mammoth/docx/uris.py @@ -3,3 +3,10 @@ def uri_to_zip_entry_name(base, uri): return uri[1:] else: return base + "/" + uri + + +def replace_fragment(uri, fragment): + hash_index = uri.find("#") + if hash_index != -1: + uri = uri[:hash_index] + return uri + "#" + fragment |
