MCPcopy
hub / github.com/pyload/pyload / fixurl

Function fixurl

module/plugins/internal/misc.py:517–537  ·  view source on GitHub ↗
(url, unquote=None)

Source from the content-addressed store, hash-verified

515
516
517def fixurl(url, unquote=None):
518 old = url
519 url = urllib.unquote(url)
520
521 if unquote is None:
522 unquote = url == old
523
524 url = decode(url)
525
526 #: 'unicode-escape' that work with unicode strings too
527 url = re.sub(r'\\u(\d{4})', lambda x: unichr(int(x.group(1))), url, flags=re.I)
528
529 url = html_unescape(url)
530
531 #: '//' becomes '/'
532 url = re.sub(r'(?<!:)/{2,}', '/', url).strip().lstrip('.')
533
534 if not unquote:
535 url = urllib.quote(url)
536
537 return url
538
539
540def truncate(name, length):

Callers 3

loadMethod · 0.85
uploadMethod · 0.85
get_infoMethod · 0.85

Calls 2

decodeFunction · 0.70
html_unescapeFunction · 0.70

Tested by

no test coverage detected