Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 17 for hasPathPrefix (0.17 sec)

  1. staging/src/k8s.io/apiserver/pkg/storage/cacher/util_test.go

    		{"a/", "a/"},
    		{"a/../", "a/../"},
    
    		// Path prefix matches
    		{"a/b", "a"},
    		{"a/b", "a/"},
    		{"中文/", "中文"},
    	}
    	for i, tc := range validTestcases {
    		if !hasPathPrefix(tc.s, tc.prefix) {
    			t.Errorf(`%d: Expected hasPathPrefix("%s","%s") to be true`, i, tc.s, tc.prefix)
    		}
    	}
    
    	invalidTestcases := []struct {
    		s      string
    		prefix string
    	}{
    		// Mismatch
    		{"a", "b"},
    
    Registered: Sat Jun 15 01:39:40 UTC 2024
    - Last Modified: Thu Jun 28 02:01:09 UTC 2018
    - 1.5K bytes
    - Viewed (0)
  2. staging/src/k8s.io/apiserver/pkg/storage/cacher/util.go

    limitations under the License.
    */
    
    package cacher
    
    import (
    	"strings"
    )
    
    // hasPathPrefix returns true if the string matches pathPrefix exactly, or if is prefixed with pathPrefix at a path segment boundary
    func hasPathPrefix(s, pathPrefix string) bool {
    	// Short circuit if s doesn't contain the prefix at all
    	if !strings.HasPrefix(s, pathPrefix) {
    		return false
    	}
    
    Registered: Sat Jun 15 01:39:40 UTC 2024
    - Last Modified: Fri Dec 15 07:09:11 UTC 2023
    - 1.3K bytes
    - Viewed (0)
  3. src/cmd/internal/objabi/line.go

    // For portability, we allow ASCII case folding, so that hasPathPrefix("a/b/c", "A/B") is true.
    // Similarly, we allow slash folding, so that hasPathPrefix("a/b/c", "a\\b") is true.
    // We do not allow full Unicode case folding, for fear of causing more confusion
    // or harm than good. (For an example of the kinds of things that can go wrong,
    // see http://article.gmane.org/gmane.linux.kernel/1853266.)
    func hasPathPrefix(s string, t string) bool {
    	if len(t) > len(s) {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Jan 17 23:10:31 UTC 2023
    - 3.8K bytes
    - Viewed (0)
  4. src/cmd/internal/pkgpattern/pkgpattern.go

    			if strings.Contains(name, vendorChar) {
    				return false
    			}
    			name = replaceVendor(name, vendorChar)
    		}
    		return reg.MatchString(name)
    	}
    }
    
    // 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):
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Sep 27 16:43:40 UTC 2022
    - 4.8K bytes
    - Viewed (0)
  5. src/cmd/go/internal/str/path.go

    // license that can be found in the LICENSE file.
    
    package str
    
    import (
    	"os"
    	"path/filepath"
    	"runtime"
    	"strings"
    )
    
    // HasPathPrefix reports whether the slash-separated path s
    // begins with the elements in prefix.
    func HasPathPrefix(s, prefix string) bool {
    	if len(s) == len(prefix) {
    		return s == prefix
    	}
    	if prefix == "" {
    		return true
    	}
    	if len(s) > len(prefix) {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Jan 31 20:33:02 UTC 2023
    - 3.9K bytes
    - Viewed (0)
  6. src/cmd/go/internal/str/str_test.go

    		{"foo/bar", "foo/", true},
    		{"foo/bar", "/foo", false},
    		{"foo/bar", "foo/bar", true},
    		{"foo/bar", "foo/bar/", false},
    		{"foo/bar", "/foo/bar", false},
    	} {
    		got := HasPathPrefix(tt.s, tt.prefix)
    		if got != tt.want {
    			t.Errorf("HasPathPrefix(%q, %q) = %v; want %v", tt.s, tt.prefix, got, tt.want)
    		}
    	}
    }
    
    func TestTrimFilePathPrefixSlash(t *testing.T) {
    	if os.PathSeparator != '/' {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Wed Jan 25 16:49:13 UTC 2023
    - 5.4K bytes
    - Viewed (0)
  7. src/cmd/internal/pkgpattern/pat_test.go

    	{"abc", "a", false},
    	{"a/bc", "a", true},
    	{"a", "a", true},
    	{"a/bc", "a/", true},
    }
    
    func TestHasPathPrefix(t *testing.T) {
    	testStringPairs(t, "hasPathPrefix", hasPathPrefixTests, hasPathPrefix)
    }
    
    type stringPairTest struct {
    	in1 string
    	in2 string
    	out bool
    }
    
    func testStringPairs(t *testing.T, name string, tests []stringPairTest, f func(string, string) bool) {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Sep 27 16:43:40 UTC 2022
    - 4.4K bytes
    - Viewed (0)
  8. cmd/import-boss/main.go

    		klog.V(5).Infof("checking %q against forbidden prefix %q", imp, forbidden)
    		if hasPathPrefix(imp, forbidden) {
    			klog.V(5).Infof("this import of %q is forbidden", imp)
    			return DepForbidden
    		}
    	}
    	for _, allowed := range r.AllowedPrefixes {
    		klog.V(5).Infof("checking %q against allowed prefix %q", imp, allowed)
    		if hasPathPrefix(imp, allowed) {
    			klog.V(5).Infof("this import of %q is allowed", imp)
    			return DepAllowed
    Registered: Sat Jun 15 01:39:40 UTC 2024
    - Last Modified: Thu May 16 12:36:49 UTC 2024
    - 14.7K bytes
    - Viewed (0)
  9. src/cmd/go/internal/modfetch/coderepo.go

    func (fi dataFileInfo) Sys() any           { return nil }
    
    func (fi dataFileInfo) String() string {
    	return fs.FormatFileInfo(fi)
    }
    
    // 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):
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Sun Apr 14 18:50:24 UTC 2024
    - 38.4K bytes
    - Viewed (0)
  10. cmd/import-boss/main_test.go

    		base:   "/foobar/qux",
    		pfx:    "/foo",
    		expect: false,
    	}, {
    		base:   "/foo/bar/bat/qux/zrb",
    		pfx:    "/foo/bar/bat",
    		expect: true,
    	}}
    
    	for _, tc := range cases {
    		ret := hasPathPrefix(tc.base, tc.pfx)
    		if ret != tc.expect {
    			t.Errorf("expected %v, got %v: (%q, %q)", tc.expect, ret, tc.base, tc.pfx)
    		}
    	}
    }
    
    func checkAllErrorStrings(t *testing.T, errs []error, expect []string) {
    Registered: Sat Jun 15 01:39:40 UTC 2024
    - Last Modified: Thu May 16 12:36:49 UTC 2024
    - 8.8K bytes
    - Viewed (0)
Back to top