MCPcopy Create free account
hub / github.com/microsoft/typescript-go / ContainsPath

Method ContainsPath

internal/tspath/path.go:1038–1043  ·  view source on GitHub ↗

ContainsPath checks whether child is contained within or equal to p. Since Path values are already rooted, reduced, and case-canonicalized, this is a simple string prefix check.

(child Path)

Source from the content-addressed store, hash-verified

1036// Since Path values are already rooted, reduced, and case-canonicalized,
1037// this is a simple string prefix check.
1038func (p Path) ContainsPath(child Path) bool {
1039 if len(p) == 0 {
1040 return false
1041 }
1042 return p == child || len(child) > len(p) && strings.HasPrefix(string(child), string(p)) && (p[len(p)-1] == '/' || child[len(p)] == '/')
1043}
1044
1045func FileExtensionIs(path string, extension string) bool {
1046 return len(path) > len(extension) && strings.HasSuffix(path, extension)

Calls 2

lenFunction · 0.85
stringEnum · 0.50

Tested by

no test coverage detected