Skip to content

Commit

Permalink
fix: ensure realm url starts with https:// or http:// (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
kuruk-mm authored Nov 13, 2023
1 parent 5635f9f commit 4160277
Showing 1 changed file with 11 additions and 0 deletions.
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

0 comments on commit 4160277

Please sign in to comment.