MCPcopy Create free account
hub / github.com/Kong/insomnia / parseGitPath

Function parseGitPath

packages/insomnia/src/sync/git/parse-git-path.ts:19–32  ·  view source on GitHub ↗
(filePath: string)

Source from the content-addressed store, hash-verified

17}
18
19const parseGitPath = (filePath: string): GitPathSegments => {
20 filePath = path.normalize(filePath);
21 // FilePath will start with the clone directory. We want to remove the clone dir, so that the
22 // segments can be extracted correctly.
23 filePath = filePath.replace(_cloneDirRegExp, '');
24 // Ignore empty and current directory '.' segments
25 const [root, type, idRaw] = filePath.split(path.sep).filter(s => s !== '' && s !== '.');
26 const id = typeof idRaw === 'string' ? idRaw.replace(/\.(json|yml)$/, '') : idRaw;
27 return {
28 root: root || null,
29 type: models.isValidType(type) ? type : null,
30 id: id || null,
31 };
32};
33
34export default parseGitPath;

Callers 5

readFileMethod · 0.85
writeFileMethod · 0.85
unlinkMethod · 0.85
readdirMethod · 0.85

Calls 2

filterMethod · 0.80
isValidTypeMethod · 0.80

Tested by

no test coverage detected