URI.gd/README.md

23 lines
1.3 KiB
Markdown
Raw Normal View History

2024-05-17 17:28:19 +02:00
# URI/URL parser
2024-05-17 17:30:09 +02:00
You want a javascript-ish `document.location` kind of dictionary for URLs? We've got your back!
Why?<br>
2024-05-17 17:28:19 +02:00
Participants of the Open Web think & communicate in URI's: now with Godot (>=4) too!
2024-05-17 17:30:09 +02:00
<br><br>
2024-05-17 17:28:19 +02:00
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 }
```