path_test.go 763 B

123456789101112131415161718192021222324252627282930313233
  1. // Copyright 2015 The Gogs Authors. All rights reserved.
  2. // Copyright 2018 Gitote. All rights reserved.
  3. //
  4. // This source code is licensed under the MIT license found in the
  5. // LICENSE file in the root directory of this source tree.
  6. package tool
  7. import (
  8. "testing"
  9. . "github.com/smartystreets/goconvey/convey"
  10. )
  11. func Test_IsSameSiteURLPath(t *testing.T) {
  12. Convey("Check if a path belongs to the same site", t, func() {
  13. testCases := []struct {
  14. url string
  15. expect bool
  16. }{
  17. {"//github.com", false},
  18. {"http://github.com", false},
  19. {"https://github.com", false},
  20. {"/\\github.com", false},
  21. {"/admin", true},
  22. {"/user/repo", true},
  23. }
  24. for _, tc := range testCases {
  25. So(IsSameSiteURLPath(tc.url), ShouldEqual, tc.expect)
  26. }
  27. })
  28. }