Files
mgmt/lang/interpret_test/TestAstFunc2/url_parser.txtar
Lourenço 1f90de31e7 lang: core: net: Add a new func for URL parsing
This is a first attempt to add a new function for URL parsing, using
go's net/url package and the simple API. This is still a barebones
implementation, there's possibility to expose more information. It also
includes simple tests.
2025-02-19 13:35:20 +01:00

23 lines
784 B
Plaintext

-- main.mcl --
import "net"
import "fmt"
$url1 = "https://www.example.com/search?q=mgmt"
$url2 = "ftp://example.com/apath"
$url3 = "https://www3.weird.url/?qu=ery"
$url_parse1 = net.url_parser($url1)
$url_parse2 = net.url_parser($url2)
$url_parse3 = net.url_parser($url3)
test [fmt.printf("%s %s %s %s", $url_parse1->scheme, $url_parse1->host, $url_parse1->path, $url_parse1->raw_query),] {}
test [fmt.printf("%s %s %s %s", $url_parse2->scheme, $url_parse2->host, $url_parse2->path, $url_parse2->raw_query),] {}
test [fmt.printf("%s %s %s %s", $url_parse3->scheme, $url_parse3->host, $url_parse3->path, $url_parse3->raw_query),] {}
-- OUTPUT --
Vertex: test[https www.example.com /search q=mgmt]
Vertex: test[ftp example.com /apath ]
Vertex: test[https www3.weird.url / qu=ery]