path.go 436 B

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