path_test.go 529 B

123456789101112131415161718192021222324252627
  1. package tool
  2. import (
  3. "testing"
  4. . "github.com/smartystreets/goconvey/convey"
  5. )
  6. func Test_IsSameSiteURLPath(t *testing.T) {
  7. Convey("Check if a path belongs to the same site", t, func() {
  8. testCases := []struct {
  9. url string
  10. expect bool
  11. }{
  12. {"//github.com", false},
  13. {"http://github.com", false},
  14. {"https://github.com", false},
  15. {"/\\github.com", false},
  16. {"/admin", true},
  17. {"/user/repo", true},
  18. }
  19. for _, tc := range testCases {
  20. So(IsSameSiteURLPath(tc.url), ShouldEqual, tc.expect)
  21. }
  22. })
  23. }