aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen van Rijn <Kelimion@users.noreply.github.com>2023-11-09 16:56:54 +0100
committerJeroen van Rijn <Kelimion@users.noreply.github.com>2023-11-09 16:56:54 +0100
commit761a079789e813cfed3a3223e05f66152bfd3a9d (patch)
tree95e56c3b46fb0e34152b867a1eb30188b6942b49
parent4116d66c599765a21d0e557250a2ae8f78937844 (diff)
Fix net.split_url
Resolves issue #2924
-rw-r--r--core/net/url.odin2
-rw-r--r--tests/core/net/test_core_net.odin5
2 files changed, 6 insertions, 1 deletions
diff --git a/core/net/url.odin b/core/net/url.odin
index ef43d6c9f..53c94d863 100644
--- a/core/net/url.odin
+++ b/core/net/url.odin
@@ -24,7 +24,7 @@ import "core:encoding/hex"
split_url :: proc(url: string, allocator := context.allocator) -> (scheme, host, path: string, queries: map[string]string) {
s := url
- i := strings.last_index(s, "://")
+ i := strings.index(s, "://")
if i >= 0 {
scheme = s[:i]
s = s[i+3:]
diff --git a/tests/core/net/test_core_net.odin b/tests/core/net/test_core_net.odin
index ab5f2e117..5326e5023 100644
--- a/tests/core/net/test_core_net.odin
+++ b/tests/core/net/test_core_net.odin
@@ -572,6 +572,11 @@ split_url_test :: proc(t: ^testing.T) {
{"a" = "", "b" = ""},
{"http://example.com/example?a&b"},
},
+ {
+ "https", "example.com", "/callback",
+ {"redirect" = "https://other.com/login"},
+ {"https://example.com/callback?redirect=https://other.com/login"},
+ },
}
for test in test_cases {