This repository has been archived by the owner on Feb 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(trusted_domains): Extract from full URL with slash suffix & impro…
…ve referer interceptor Signed-off-by: qwqcode <[email protected]>
- Loading branch information
Showing
3 changed files
with
72 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package http | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func Test_extractURLForCorsConf(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
urls string | ||
want string | ||
}{ | ||
{name: "URL with slash suffix", urls: "https://qwqaq.com/", want: "https://qwqaq.com"}, | ||
{name: "URL with path", urls: "https://qwqaq.com/test-page/", want: "https://qwqaq.com"}, | ||
{name: "URL with port and path", urls: "https://qwqaq.com:12345/test-page/", want: "https://qwqaq.com:12345"}, | ||
{name: "URL with http schema", urls: "http://qwqaq.com", want: "http://qwqaq.com"}, | ||
{name: "URL with regexp, port and path", urls: "http://*.qwqaq.com:12345/test-page/", want: "http://*.qwqaq.com:12345"}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
if got := extractURLForCorsConf(tt.urls); got != tt.want { | ||
t.Errorf("extractURLForCorsConf() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bac1271
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related #36