github.com/mcuadros/ascode@v1.3.1/starlark/module/url/testdata/test.star (about) 1 load('url', 'url') 2 load('assert.star', 'assert') 3 4 5 assert.eq(url.query_escape("/foo&bar qux"), "%2Ffoo%26bar+qux") 6 assert.eq(url.query_unescape("%2Ffoo%26bar+qux"), "/foo&bar qux") 7 assert.fails(lambda: url.query_unescape("%ssf"), 'invalid URL escape "%ss"') 8 9 assert.eq(url.path_escape("/foo&bar qux"), "%2Ffoo&bar%20qux") 10 assert.eq(url.path_unescape("%2Ffoo&bar%20qux"), "/foo&bar qux") 11 assert.fails(lambda: url.path_unescape("%ssf"), 'invalid URL escape "%ss"') 12 13 r = url.parse("http://qux:bar@bing.com/search?q=dotnet#foo") 14 assert.eq(r.scheme, "http") 15 assert.eq(r.opaque, "") 16 assert.eq(r.username, "qux") 17 assert.eq(r.password, "bar") 18 assert.eq(r.host, "bing.com") 19 assert.eq(r.path, "/search") 20 assert.eq(r.raw_query, "q=dotnet") 21 assert.eq(r.fragment, "foo") 22 23 r = url.parse("http://qux:@bing.com/search?q=dotnet#foo") 24 assert.eq(r.username, "qux") 25 assert.eq(r.password, "") 26 27 r = url.parse("http://qux@bing.com/search?q=dotnet#foo") 28 assert.eq(r.username, "qux") 29 assert.eq(r.password, None) 30 31 r = url.parse("http://bing.com/search?q=dotnet#foo") 32 assert.eq(r.username, None) 33 assert.eq(r.password, None) 34 35 assert.fails(lambda: url.parse("%ssf"), 'invalid URL escape "%ss"')