mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-03-29 13:09:07 +00:00
34 lines
993 B
TypeScript
34 lines
993 B
TypeScript
/**
|
|
* file list returns path starting with ./blah
|
|
* rename returns simply blah.
|
|
* Both are the same. This method only handles these two cases and no other complicated paths that may contain ..
|
|
* ./ inside the path.
|
|
* TODO: this should go away when not using jupyter for file operations and use normalized paths.
|
|
* @param path1
|
|
* @param path2
|
|
*/
|
|
export function isPathEqual(path1: string, path2: string): boolean {
|
|
const normalize = (path: string): string => {
|
|
const dotSlash = "./";
|
|
if (path.indexOf(dotSlash) === 0) {
|
|
path = path.substring(dotSlash.length);
|
|
}
|
|
return path;
|
|
};
|
|
|
|
return normalize(path1) === normalize(path2);
|
|
}
|
|
|
|
/**
|
|
* Remove extension
|
|
* @param path
|
|
* @param extension Without the ".". e.g. "ipynb" (and not ".ipynb")
|
|
*/
|
|
export function stripExtension(path: string, extension: string): string {
|
|
const splitted = path.split(".");
|
|
if (splitted[splitted.length - 1] === extension) {
|
|
splitted.pop();
|
|
}
|
|
return splitted.join(".");
|
|
}
|