diff options
author | Tobias Kortkamp <tobik@FreeBSD.org> | 2021-09-07 20:12:43 +0000 |
---|---|---|
committer | Tobias Kortkamp <tobik@FreeBSD.org> | 2021-09-08 19:05:18 +0000 |
commit | 217c3e9d72809ea59cc041ee83bcc49080c9eef5 (patch) | |
tree | d75683a2659a1a6cf68032a22c72023c8eea59fb /Mk | |
parent | 7e42f13ff326c08b255070d182542ecab813ee6a (diff) | |
download | ports-217c3e9d72809ea59cc041ee83bcc49080c9eef5.tar.gz ports-217c3e9d72809ea59cc041ee83bcc49080c9eef5.zip |
Scripts/split-url.awk: Split query strings too
Also reset state on function entry otherwise split_url() cannot
really be called multiple times since there would be garbage values
in the url array from previous calls.
Diffstat (limited to 'Mk')
-rw-r--r-- | Mk/Scripts/split-url.awk | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/Mk/Scripts/split-url.awk b/Mk/Scripts/split-url.awk index 34506b527dd8..f62af4219ad6 100644 --- a/Mk/Scripts/split-url.awk +++ b/Mk/Scripts/split-url.awk @@ -1,4 +1,5 @@ -function split_url(s, url_scheme, url_fragment, url_query, url_authority, url_auth, url_user, url_host) { +function split_url(s, url_scheme, url_fragment, url_query, url_query_parts, i, url_query_part, url_authority, url_auth, url_user, url_host) { + delete url # scheme:[//[user[:password]@]host[:port]][/path][?query][#fragment] split(s, url_scheme, "://") url["scheme"] = url_scheme[1] @@ -7,7 +8,15 @@ function split_url(s, url_scheme, url_fragment, url_query, url_authority, url_au url["fragment"] = url_fragment[2] split(url_fragment[1], url_query, "?") - url["query"] = url_query[2] + + split(url_query[2], url_query_parts, "&") + # url["query"] list of query keys (space separated) + # url["query", key] value + for (i = 1; i <= length(url_query_parts); i++) { + split(url_query_parts[i], url_query_part, "=") + url["query"] = url["query"] " " url_query_part[1] + url["query", url_query_part[1]] = url_query_part[2] + } split(url_query[1], url_authority, "/") url["path"] = substr(url_query[1], length(url_authority[1]) + 1) |