28 lines
		
	
	
		
			614 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
		
			614 B
		
	
	
	
		
			Go
		
	
	
	
	
	
// Copyright 2017 The Go Authors. All rights reserved.
 | 
						|
// Use of this source code is governed by a BSD-style
 | 
						|
// license that can be found in the LICENSE file.
 | 
						|
 | 
						|
// +build go1.9
 | 
						|
 | 
						|
package load
 | 
						|
 | 
						|
import (
 | 
						|
	"strings"
 | 
						|
)
 | 
						|
 | 
						|
// hasPathPrefix reports whether the path s begins with the
 | 
						|
// elements in prefix.
 | 
						|
func hasPathPrefix(s, prefix string) bool {
 | 
						|
	switch {
 | 
						|
	default:
 | 
						|
		return false
 | 
						|
	case len(s) == len(prefix):
 | 
						|
		return s == prefix
 | 
						|
	case len(s) > len(prefix):
 | 
						|
		if prefix != "" && prefix[len(prefix)-1] == '/' {
 | 
						|
			return strings.HasPrefix(s, prefix)
 | 
						|
		}
 | 
						|
		return s[len(prefix)] == '/' && s[:len(prefix)] == prefix
 | 
						|
	}
 | 
						|
}
 |