| 902 | } |
| 903 | |
| 904 | func PathIsRelative(path string) bool { |
| 905 | // True if path is ".", "..", or starts with "./", "../", ".\\", or "..\\". |
| 906 | |
| 907 | if path == "." || path == ".." { |
| 908 | return true |
| 909 | } |
| 910 | |
| 911 | if len(path) >= 2 && path[0] == '.' && (path[1] == '/' || path[1] == '\\') { |
| 912 | return true |
| 913 | } |
| 914 | |
| 915 | if len(path) >= 3 && path[0] == '.' && path[1] == '.' && (path[2] == '/' || path[2] == '\\') { |
| 916 | return true |
| 917 | } |
| 918 | |
| 919 | return false |
| 920 | } |
| 921 | |
| 922 | // EnsurePathIsNonModuleName ensures a path is either absolute (prefixed with `/` or `c:`) or dot-relative (prefixed |
| 923 | // with `./` or `../`) so as not to be confused with an unprefixed module name. |