Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should normalize a string path', () => {
const path = PathExt.normalize('./fixtures///b/../b/c.js');
expect(path).to.equal('fixtures/b/c.js');
});
it('should not return "." for an empty path', () => {
const path = PathExt.normalize('');
expect(path).to.equal('');
});
});
normalize(path: string): string {
const parts = path.split(':');
if (parts.length === 1) {
return PathExt.normalize(path);
}
return `${parts[0]}:${PathExt.normalize(parts.slice(1).join(':'))}`;
}
normalize(path: string): string {
const parts = path.split(':');
if (parts.length === 1) {
return PathExt.normalize(path);
}
return `${parts[0]}:${PathExt.normalize(parts.slice(1).join(':'))}`;
}
findWidget(
path: string,
widgetName: string | null = 'default'
): IDocumentWidget | undefined {
let newPath = PathExt.normalize(path);
let widgetNames = [widgetName];
if (widgetName === 'default') {
let factory = this.registry.defaultWidgetFactory(newPath);
if (!factory) {
return undefined;
}
widgetNames = [factory.name];
} else if (widgetName === null) {
widgetNames = this.registry
.preferredWidgetFactories(newPath)
.map(f => f.name);
}
for (let context of this._contextsForPath(newPath)) {
for (const widgetName of widgetNames) {
let widget = this._widgetManager.findWidget(context, widgetName);
findWidget(
path: string,
widgetName: string | null = 'default'
): IDocumentWidget | undefined {
let newPath = PathExt.normalize(path);
let widgetNames = [widgetName];
if (widgetName === 'default') {
let factory = this.registry.defaultWidgetFactory(newPath);
if (!factory) {
return undefined;
}
widgetNames = [factory.name];
} else if (widgetName === null) {
widgetNames = this.registry
.preferredWidgetFactories(newPath)
.map(f => f.name);
}
for (let context of this._contextsForPath(newPath)) {
for (const widgetName of widgetNames) {
let widget = this._widgetManager.findWidget(context, widgetName);
findWidget(
path: string,
widgetName: string | null = 'default'
): IDocumentWidget | undefined {
let newPath = PathExt.normalize(path);
let widgetNames = [widgetName];
if (widgetName === 'default') {
let factory = this.registry.defaultWidgetFactory(newPath);
if (!factory) {
return undefined;
}
widgetNames = [factory.name];
} else if (widgetName === null) {
widgetNames = this.registry
.preferredWidgetFactories(newPath)
.map(f => f.name);
}
for (let context of this._contextsForPath(newPath)) {
for (const widgetName of widgetNames) {
let widget = this._widgetManager.findWidget(context, widgetName);