From d0b4eb76001049a23fe038025cfa56472703fa70 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Thu, 18 May 2017 20:12:25 +0100 Subject: Avoid parsing URI when replacing fragment --- mammoth/docx/uris.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'mammoth/docx/uris.py') 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 -- cgit v1.2.3