Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions tools/customlint/testdata/typedpaths/typedpaths.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ func badConstructorConstants() {
_ = tspath.RootedFilePathFromAbsolute("relative/path")
_ = tspath.RootedDirectoryPathFromAbsolute("relative/path")
_ = tspath.RootedPathFromNormalized("")
_ = tspath.RootedPathFromNormalized("c:d://server/a?b")
_ = tspath.RootedPathFromNormalized("1:x://server/a#b")
_ = tspath.RootedPathFromAbsolute("1://server/a?b")
_ = tspath.RootedFilePathFromNormalized("/project/../file.ts")
_ = tspath.RootedDirectoryPathFromNormalized("/project/")
_ = tspath.RelativePathFromNormalized("/project/file.ts")
Expand All @@ -132,6 +135,11 @@ func goodConstructorConstants(dynamic string) {
_ = tspath.RootedDirectoryPathFromAbsolute("file:///project")
_ = tspath.RootedPathFromNormalized("/")
_ = tspath.RootedPathFromNormalized("FILE:///C:/")
_ = tspath.RootedPathFromNormalized("C:/a?b#c")
_ = tspath.RootedPathFromAbsolute("c:/d://server/a?b")
_ = tspath.RootedPathFromNormalized("c:d://server/a")
_ = tspath.RootedPathFromNormalized("1:x://server/a")
_ = tspath.RootedPathFromNormalized("1://server/a")
_ = tspath.RootedFilePathFromNormalized(constantRoot + "/file.ts")
_ = tspath.RootedDirectoryPathFromNormalized("^/untitled")
_ = tspath.RelativePathFromNormalized("../project/")
Expand Down
14 changes: 14 additions & 0 deletions tools/customlint/testdata/typedpaths/typedpaths.go.golden
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,15 @@
_ = tspath.RootedPathFromNormalized("")
~
!!! typedpaths: constant argument to RootedPathFromNormalized must be rooted and normalized
_ = tspath.RootedPathFromNormalized("c:d://server/a?b")
~
!!! typedpaths: constant argument to RootedPathFromNormalized must be rooted and normalized
_ = tspath.RootedPathFromNormalized("1:x://server/a#b")
~
!!! typedpaths: constant argument to RootedPathFromNormalized must be rooted and normalized
_ = tspath.RootedPathFromAbsolute("1://server/a?b")
~
!!! typedpaths: constant argument to RootedPathFromAbsolute must be absolute
_ = tspath.RootedFilePathFromNormalized("/project/../file.ts")
~
!!! typedpaths: constant argument to RootedFilePathFromNormalized must be rooted and normalized
Expand Down Expand Up @@ -238,6 +247,11 @@
_ = tspath.RootedDirectoryPathFromAbsolute("file:///project")
_ = tspath.RootedPathFromNormalized("/")
_ = tspath.RootedPathFromNormalized("FILE:///C:/")
_ = tspath.RootedPathFromNormalized("C:/a?b#c")
_ = tspath.RootedPathFromAbsolute("c:/d://server/a?b")
_ = tspath.RootedPathFromNormalized("c:d://server/a")
_ = tspath.RootedPathFromNormalized("1:x://server/a")
_ = tspath.RootedPathFromNormalized("1://server/a")
_ = tspath.RootedFilePathFromNormalized(constantRoot + "/file.ts")
_ = tspath.RootedDirectoryPathFromNormalized("^/untitled")
_ = tspath.RelativePathFromNormalized("../project/")
Expand Down
9 changes: 3 additions & 6 deletions tools/customlint/typedpaths.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,8 @@ func isLiteralURLPath(path string) bool {
if path == "" ||
path[0] == '/' ||
path[0] == '\\' ||
len(path) > 1 && path[1] == ':' ||
len(path) > 1 && isLiteralVolumeCharacter(path[0]) && path[1] == ':' &&
(len(path) == 2 || path[2] == '/' || path[2] == '\\') ||
strings.HasPrefix(path, "^/") {
return false
}
Expand Down Expand Up @@ -474,11 +475,7 @@ func isLiteralCanonicalPath(path string) bool {
}

func literalURLPathPart(path string) string {
if path == "" ||
path[0] == '/' ||
path[0] == '\\' ||
len(path) > 1 && path[1] == ':' ||
strings.HasPrefix(path, "^/") {
if !isLiteralURLPath(path) {
return path
}
schemeEnd := strings.Index(path, "://")
Expand Down
Loading