Leon van Kammen b80a259402 | ||
---|---|---|
README.md | ||
URI.gd |
README.md
URI/URL parser
You want a javascript-ish document.location
kind of dictionary for URLs? We've got your back!
Why?
Participants of the Open Web think & communicate in URI's: now with Godot (>=4) too!
This class will not win the beauty contest related to RFC 3986, but here goes:
USAGE
xrf = preload("res://URI.gd").new()
print( URI.parse("https://foo.com/a/bc.gltf?bar=2#foo=2") )
print( URI.parse("a/bc.gltf?a=1#foo=2") )
OUTPUT:
{ "domain": "foo.com", "fragment": { "foo": { "string": "2", "x": <null>, "y": <null>, "color": <null>, "float": <null>, "int": <null> } }, "file": "bc.gltf", "URN": "https://foo.com/a/bc.gltf?bar=2#foo=2", "string": "https://foo.com/a/bc.gltf?bar=2#foo=2", "protocol": "https", "path": "a/bc.gltf", "query": { "bar": { "string": "2", "x": <null>, "y": <null>, "color": <null>, "float": <null>, "int": <null> } }, "hash": "#foo=2", "isLocal": false }
{ "domain": "", "fragment": { "foo": { "string": "2", "x": <null>, "y": <null>, "color": <null>, "float": <null>, "int": <null> } }, "file": "bc.gltf", "URN": "", "string": "a/bc.gltf?a=1#foo=2", "protocol": "", "path": "a/bc.gltf", "query": { "a": { "string": "1", "x": <null>, "y": <null>, "color": <null>, "float": <null>, "int": <null> } }, "hash": "#foo=2", "isLocal": true }