From 761a079789e813cfed3a3223e05f66152bfd3a9d Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Thu, 9 Nov 2023 16:56:54 +0100 Subject: [PATCH] Fix net.split_url Resolves issue #2924 --- core/net/url.odin | 2 +- tests/core/net/test_core_net.odin | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) 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 {