path.go 509 B

12345678910111213141516
  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. // IsSameSiteURLPath returns true if the URL path belongs to the same site, false otherwise.
  8. // False: //url, http://url, /\url
  9. // True: /url
  10. func IsSameSiteURLPath(url string) bool {
  11. return len(url) >= 2 && url[0] == '/' && url[1] != '/' && url[1] != '\\'
  12. }