-
Notifications
You must be signed in to change notification settings - Fork 741
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Scripts/cargo-crates.awk: Move split_url() to separate file
Also stop leaking local variables
- Loading branch information
Tobias Kortkamp
authored and
Tobias Kortkamp
committed
Sep 7, 2021
1 parent
0ef8700
commit d8fbaa5
Showing
3 changed files
with
30 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
function split_url(s, url_scheme, url_fragment, url_query, url_authority, url_auth, url_user, url_host) { | ||
# scheme:[//[user[:password]@]host[:port]][/path][?query][#fragment] | ||
split(s, url_scheme, "://") | ||
url["scheme"] = url_scheme[1] | ||
|
||
split(url_scheme[2], url_fragment, "#") | ||
url["fragment"] = url_fragment[2] | ||
|
||
split(url_fragment[1], url_query, "?") | ||
url["query"] = url_query[2] | ||
|
||
split(url_query[1], url_authority, "/") | ||
url["path"] = substr(url_query[1], length(url_authority[1]) + 1) | ||
|
||
split(url_authority[1], url_auth, "@") | ||
|
||
if (length(url_auth) == 2) { | ||
split(url_auth[1], url_user, ":") | ||
url["user"] = url_user[1] | ||
url["password"] = url_user[2] | ||
split(url_auth[2], url_host, ":") | ||
} else { | ||
url["user"] = "" | ||
url["password"] = "" | ||
split(url_auth[1], url_host, ":") | ||
} | ||
url["host"] = url_host[1] | ||
url["port"] = url_host[2] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters