url
The file builtins\url.e (not an autoinclude) contains some basic routines for dealing with urls.
The code is fairly straightforward and open to enhancements/suggestions.
Since it is all just text processing, it is perfectly compatible with pwa/p2js.
Elements returned by parse_url() are 0 when not available/recognised, apart from a protocol of "".
Some further examples can be found at https://rosettacode.org/mw/index.php?title=URL_parser#Phix.
The code is fairly straightforward and open to enhancements/suggestions.
Since it is all just text processing, it is perfectly compatible with pwa/p2js.
Example:
include url.e
?parse_url("http://user:pass@www.debian.org:80/index.html?name=John&age=39#tag")
?parse_url("mailto:John.Doe@example.com")
?decode_url("Fred+%26+Ethel")
-- output:
-- {"http","www.debian.org",80'P',"/index.html","user","pass","name=John&age=39","tag"}
-- {"mailto",0,0,"John.Doe@example.com",0,0,0,0}
-- "Fred & Ethel"
Some further examples can be found at https://rosettacode.org/mw/index.php?title=URL_parser#Phix.
Constants
|
| -- [1] The protocol of the URL, aka scheme, eg "http" |
|
| -- [2] The hostname of the URL, aka domain, eg "www.example.com" |
|
| -- [3] The TCP port that the URL will connect to, eg 80 |
|
| -- [4] The protocol-specific pathname of the URL, eg "/index.html" |
|
| -- [5] The username of the URL, eg "user" |
|
| -- [6] The password of the URL, eg "pass" |
|
| -- [7] The HTTP query string, eg "name=John&age=39" |
|
| -- [8] The #name part, eg "tag" |
Routines
| object res = |
|
| string desc = |
|
| string url = |
decode_url(string url) -- Convert all encoded entities to their decoded counter parts |