Browse Source

Merge pull request #2937 from Kelimion/fix_net_split

Fix net.split_url
Jeroen van Rijn 1 year ago
parent
commit
70c1f9d0e1
2 changed files with 6 additions and 1 deletions
  1. 1 1
      core/net/url.odin
  2. 5 0
      tests/core/net/test_core_net.odin

+ 1 - 1
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:]

+ 5 - 0
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 {