Remove useless helper
This commit is contained in:
parent
1d7ececd00
commit
a1d4c886b9
|
@ -1,20 +1,10 @@
|
|||
# Extract the named capturing groups of a regular expression into a
|
||||
# {name: matched text} mapping.
|
||||
def regex_capture(regex):
|
||||
match(regex).captures
|
||||
| [
|
||||
.[]
|
||||
| select(.name)
|
||||
| { key: .name, value: .string }
|
||||
] | from_entries;
|
||||
|
||||
# Parse URLs into an object with {scheme, netloc, path, params, query, fragment}.
|
||||
# Similar to Python's urllib.parse.urlparse.
|
||||
def urlparse: regex_capture("^(?:(?<scheme>[^:/?#]+):)?(?://(?<netloc>[^/?#]*))?(?:(?<path>(?:[^?#]+/)?[^?#;]*)(?:;(?<params>[^?#/]*))?)?(?:\\?(?<query>[^#]*))?(?:#(?<fragment>.*))?$");
|
||||
def urlparse: capture("^(?:(?<scheme>[^:/?#]+):)?(?://(?<netloc>[^/?#]*))?(?:(?<path>(?:[^?#]+/)?[^?#;]*)(?:;(?<params>[^?#/]*))?)?(?:\\?(?<query>[^#]*))?(?:#(?<fragment>.*))?$");
|
||||
|
||||
# Parse URLs into an object with {scheme, netloc, path, query, fragment}. Path parameters are not parsed.
|
||||
# Similar to Python's urllib.parse.urlsplit.
|
||||
def urlsplit: regex_capture("^(?:(?<scheme>[^:/?#]+):)?(?://(?<netloc>[^/?#]*))?(?<path>(?:[^?#]+/)?[^?#]*)?(?:\\?(?<query>[^#]*))?(?:#(?<fragment>.*))?$");
|
||||
def urlsplit: capture("^(?:(?<scheme>[^:/?#]+):)?(?://(?<netloc>[^/?#]*))?(?<path>(?:[^?#]+/)?[^?#]*)?(?:\\?(?<query>[^#]*))?(?:#(?<fragment>.*))?$");
|
||||
|
||||
# Reverse operation of either urlparse or urlsplit.
|
||||
def urlunparse:
|
||||
|
|
Loading…
Reference in New Issue