MCPcopy Create free account
hub / github.com/deepnote/vscode-deepnote / parse

Function parse

src/platform/vscode-path/path.ts:917–1067  ·  view source on GitHub ↗
(path)

Source from the content-addressed store, hash-verified

915 format: _format.bind(null, '\\'),
916
917 parse(path) {
918 validateString(path, 'path');
919
920 const ret = { root: '', dir: '', base: '', ext: '', name: '' };
921 if (path.length === 0) {
922 return ret;
923 }
924
925 const len = path.length;
926 let rootEnd = 0;
927 let code = path.charCodeAt(0);
928
929 if (len === 1) {
930 if (isPathSeparator(code)) {
931 // `path` contains just a path separator, exit early to avoid
932 // unnecessary work
933 ret.root = ret.dir = path;
934 return ret;
935 }
936 ret.base = ret.name = path;
937 return ret;
938 }
939 // Try to match a root
940 if (isPathSeparator(code)) {
941 // Possible UNC root
942
943 rootEnd = 1;
944 if (isPathSeparator(path.charCodeAt(1))) {
945 // Matched double path separator at beginning
946 let j = 2;
947 let last = j;
948 // Match 1 or more non-path separators
949 while (j < len && !isPathSeparator(path.charCodeAt(j))) {
950 j++;
951 }
952 if (j < len && j !== last) {
953 // Matched!
954 last = j;
955 // Match 1 or more path separators
956 while (j < len && isPathSeparator(path.charCodeAt(j))) {
957 j++;
958 }
959 if (j < len && j !== last) {
960 // Matched!
961 last = j;
962 // Match 1 or more non-path separators
963 while (j < len && !isPathSeparator(path.charCodeAt(j))) {
964 j++;
965 }
966 if (j === len) {
967 // We matched a UNC root only
968 rootEnd = j;
969 } else if (j !== last) {
970 // We matched a UNC root with leftovers
971 rootEnd = j + 1;
972 }
973 }
974 }

Callers 4

parseVariableViewHTMLFunction · 0.50
getCondaVersionFunction · 0.50
getExecutablePathFunction · 0.50
parseSemVerFunction · 0.50

Calls 3

validateStringFunction · 0.85
isWindowsDeviceRootFunction · 0.85
isPathSeparatorFunction · 0.70

Tested by

no test coverage detected