|
// retoor <retoor@molodetz.nl>
|
|
|
|
import "web" for Client
|
|
|
|
var parsed1 = Client.parseUrl_("http://example.com/path")
|
|
System.print(parsed1["scheme"]) // expect: http
|
|
System.print(parsed1["host"]) // expect: example.com
|
|
System.print(parsed1["port"]) // expect: 80
|
|
System.print(parsed1["path"]) // expect: /path
|
|
|
|
var parsed2 = Client.parseUrl_("https://example.com/path")
|
|
System.print(parsed2["scheme"]) // expect: https
|
|
System.print(parsed2["port"]) // expect: 443
|
|
|
|
var parsed3 = Client.parseUrl_("http://example.com:8080/api/v1")
|
|
System.print(parsed3["host"]) // expect: example.com
|
|
System.print(parsed3["port"]) // expect: 8080
|
|
System.print(parsed3["path"]) // expect: /api/v1
|
|
|
|
var parsed4 = Client.parseUrl_("https://api.example.com")
|
|
System.print(parsed4["host"]) // expect: api.example.com
|
|
System.print(parsed4["path"]) // expect: /
|
|
|
|
var parsed5 = Client.parseUrl_("http://localhost:3000/")
|
|
System.print(parsed5["host"]) // expect: localhost
|
|
System.print(parsed5["port"]) // expect: 3000
|
|
System.print(parsed5["path"]) // expect: /
|