path_test.go 693 B

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