Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
while (target && target.parentElement) {
if (target.classList.contains(DROP_TARGET_CLASS)) {
target.classList.remove(DROP_TARGET_CLASS);
break;
}
target = target.parentElement;
}
// Get the path based on the target node.
let index = ArrayExt.findFirstIndex(this._crumbs, node => node === target);
if (index === -1) {
return;
}
const model = this._model;
const path = PathExt.resolve(model.path, BREAD_CRUMB_PATHS[index]);
const manager = model.manager;
// Move all of the items.
let promises: Promise[] = [];
let oldPaths = event.mimeData.getData(CONTENTS_MIME) as string[];
for (let oldPath of oldPaths) {
let localOldPath = manager.services.contents.localPath(oldPath);
let name = PathExt.basename(localOldPath);
let newPath = PathExt.join(path, name);
promises.push(renameFile(manager, oldPath, newPath));
}
void Promise.all(promises).catch(err => {
return showErrorMessage('Move Error', err);
});
}
function rename(manager: IServiceManager, oldPath: string, newPath: string, basePath = ''): Promise {
// Normalize paths.
oldPath = PathExt.resolve(basePath, oldPath);
newPath = PathExt.resolve(basePath, newPath);
return manager.contents.rename(oldPath, newPath);
}
function rename(manager: IServiceManager, oldPath: string, newPath: string, basePath = ''): Promise {
// Normalize paths.
oldPath = PathExt.resolve(basePath, oldPath);
newPath = PathExt.resolve(basePath, newPath);
return manager.contents.rename(oldPath, newPath);
}
it('should resolve a sequence of paths to an absolute path on the server', () => {
const path = PathExt.resolve('var/src', '../', 'file/');
expect(path.indexOf('var/file')).to.not.equal(-1);
});
});
function normalizePath(root: string, path: string): string {
let parts = root.split(':');
if (parts.length === 1) {
return PathExt.resolve(root, path);
} else {
let resolved = PathExt.resolve(parts[1], path);
return parts[0] + ':' + resolved;
}
}
}
function normalizePath(root: string, path: string): string {
let parts = root.split(':');
if (parts.length === 1) {
return PathExt.resolve(root, path);
} else {
let resolved = PathExt.resolve(parts[1], path);
return parts[0] + ':' + resolved;
}
}
}
function deleteFile(manager: IServiceManager, path: string, basePath = ''): Promise {
path = PathExt.resolve(basePath, path);
return stopIfNeeded(manager, path).then(() => {
return manager.contents.delete(path);
});
}