@@ -12,25 +12,30 @@ func TestNormalizeHost(t *testing.T) {
1212 expected string
1313 }{
1414 // Empty input
15- {"" , "https:// " },
16- {" " , "https:// " },
15+ {"" , "" },
16+ {" " , "" },
1717
1818 // Already has https://
1919 {"https://example.databricks.com" , "https://example.databricks.com" },
20- {"HTTPS://EXAMPLE.DATABRICKS.COM" , "HTTPS://EXAMPLE.DATABRICKS.COM" },
21- {"https://example.databricks.com/" , "https://example.databricks.com/" },
20+ {"https://example.databricks.com/" , "https://example.databricks.com" },
2221
2322 // Missing protocol (should add https://)
2423 {"example.databricks.com" , "https://example.databricks.com" },
2524 {" example.databricks.com " , "https://example.databricks.com" },
2625 {"subdomain.example.databricks.com" , "https://subdomain.example.databricks.com" },
26+ {"example.databricks.com/" , "https://example.databricks.com" },
27+
28+ // Paths, query strings, and anchors are stripped
29+ {"https://example.databricks.com/path" , "https://example.databricks.com" },
30+ {"https://example.databricks.com/path/" , "https://example.databricks.com" },
31+ {"https://example.databricks.com?query" , "https://example.databricks.com" },
32+ {"https://example.databricks.com#anchor" , "https://example.databricks.com" },
2733
2834 // Edge cases
2935 {"https://" , "https://" },
3036 {"example.com" , "https://example.com" },
31- {"https://example.databricks.com/path" , "https://example.databricks.com/path" },
32- {"https://example.databricks.com/path/" , "https://example.databricks.com/path/" },
3337 {"http://localhost:8080" , "http://localhost:8080" },
38+ {"http://localhost:8080/" , "http://localhost:8080" },
3439 }
3540
3641 for _ , test := range tests {
@@ -50,15 +55,13 @@ func TestValidateHost(t *testing.T) {
5055 err = validateHost ("http://host" )
5156 assert .ErrorContains (t , err , "must start with https://" )
5257 err = validateHost ("ftp://host" )
58+ assert .ErrorContains (t , err , "must start with https://" )
5359
5460 // Must use empty path
55- assert .ErrorContains (t , err , "must start with https://" )
5661 err = validateHost ("https://host/path" )
5762 assert .ErrorContains (t , err , "must use empty path" )
5863
59- // Ignore query params
60- err = validateHost ("https://host/?query" )
61- assert .NoError (t , err )
62- err = validateHost ("https://host/" )
64+ // Valid hosts
65+ err = validateHost ("https://host" )
6366 assert .NoError (t , err )
6467}
0 commit comments