Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ensure realm url starts with https:// or http:// #89

Merged
merged 1 commit into from
Nov 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions godot/src/logic/realm.gd
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ static func ensure_ends_with_slash(str_param: String) -> String:
return str_param.trim_suffix("/") + "/"


static func ensure_starts_with_https(str_param: String) -> String:
if str_param.begins_with("https://"):
return str_param

if str_param.begins_with("http://"):
return str_param

return "https://" + str_param


static func resolve_realm_url(value: String) -> String:
if Realm.is_dcl_ens(value):
return Realm.dcl_world_url(value)
Expand Down Expand Up @@ -60,6 +70,7 @@ static func parse_urn(urn: String):
func set_realm(new_realm_string: String) -> void:
realm_string = new_realm_string
realm_url = ensure_ends_with_slash(resolve_realm_url(realm_string))
realm_url = ensure_starts_with_https(realm_url)
var promise: Promise = http_requester.request_json(
realm_url + "about", HTTPClient.METHOD_GET, "", []
)
Expand Down
Loading