diff options
Diffstat (limited to 'python/fatcat_web/hacks.py')
-rw-r--r-- | python/fatcat_web/hacks.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/python/fatcat_web/hacks.py b/python/fatcat_web/hacks.py index 9e6f6ab5..06350b41 100644 --- a/python/fatcat_web/hacks.py +++ b/python/fatcat_web/hacks.py @@ -1,17 +1,23 @@ - import re STRIP_EXTLINK_XML_RE = re.compile(r"<ext-link.*xlink:type=\"simple\">") + def strip_extlink_xml(unstr): unstr = unstr.replace("</ext-link>", "") unstr = STRIP_EXTLINK_XML_RE.sub("", unstr) return unstr + def test_strip_extlink_xml(): assert strip_extlink_xml("asdf") == "asdf" - assert strip_extlink_xml("""LOCKSS (2014) Available: <ext-link xmlns:xlink="http://www.w3.org/1999/xlink" ext-link-type="uri" xlink:href="http://lockss.org/" xlink:type="simple">http://lockss.org/</ext-link>. Accessed: 2014 November 1.""") == \ - """LOCKSS (2014) Available: http://lockss.org/. Accessed: 2014 November 1.""" + assert ( + strip_extlink_xml( + """LOCKSS (2014) Available: <ext-link xmlns:xlink="http://www.w3.org/1999/xlink" ext-link-type="uri" xlink:href="http://lockss.org/" xlink:type="simple">http://lockss.org/</ext-link>. Accessed: 2014 November 1.""" + ) + == """LOCKSS (2014) Available: http://lockss.org/. Accessed: 2014 November 1.""" + ) + def wayback_suffix(entity): """ |