mirror of
https://github.com/thegatesbrowser/thegates.git
synced 2025-08-27 11:17:48 -04:00
add license, move folders
This commit is contained in:
parent
185cc74060
commit
271c4a46a1
132 changed files with 21 additions and 0 deletions
29
app/scripts/url.gd
Normal file
29
app/scripts/url.gd
Normal file
|
@ -0,0 +1,29 @@
|
|||
extends RefCounted
|
||||
class_name Url
|
||||
|
||||
const url_regex: String = "^(https?)://[^\\s()<>]+(?:\\([\\w\\d]+\\)|([^[:punct:]\\s]|/))$"
|
||||
|
||||
|
||||
static func join(base_url: String, path: String) -> String:
|
||||
var url = ""
|
||||
if path.is_empty():
|
||||
url = base_url
|
||||
elif path.begins_with("http"):
|
||||
url = path
|
||||
else:
|
||||
url = base_url.get_base_dir() + "/" + path
|
||||
return url
|
||||
|
||||
|
||||
static func fix_gate_url(url: String) -> String:
|
||||
if url.get_extension() != "gate":
|
||||
var slash = "" if url.ends_with("/") else "/"
|
||||
url += slash + "world.gate"
|
||||
return url
|
||||
|
||||
|
||||
static func is_valid(url: String) -> bool:
|
||||
var regex = RegEx.new()
|
||||
regex.compile(url_regex)
|
||||
var result = regex.search(url)
|
||||
return false if result == null else result.get_string() == url
|
Loading…
Add table
Add a link
Reference in a new issue