当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript uri.from函数代码示例

本文整理汇总了TypeScript中vs/base/common/uri.from函数的典型用法代码示例。如果您正苦于以下问题:TypeScript from函数的具体用法?TypeScript from怎么用?TypeScript from使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了from函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: test

	test('URI#toString, don\'t encode port', () => {
		var value = URI.parse('http://localhost:8080/far');
		assert.equal(value.toString(), 'http://localhost:8080/far');

		value = URI.from({ scheme: 'http', authority: 'löcalhost:8080', path: '/far', query: undefined, fragment: undefined });
		assert.equal(value.toString(), 'http://l%C3%B6calhost:8080/far');
	});
开发者ID:AjuanM,项目名称:vscode,代码行数:7,代码来源:uri.test.ts

示例2: migrateStorageToMultiRootWorkspace

export function migrateStorageToMultiRootWorkspace(fromWorkspaceId: string, toWorkspace: IWorkspaceIdentifier, storage: IStorage): string {
	const parsed = parseStorage(storage);

	const newWorkspaceId = URI.from({ path: toWorkspace.id, scheme: 'root' }).toString();

	// Find in which location the workspace storage is to be migrated from
	let storageForWorkspace: StorageObject;
	if (parsed.multiRoot.has(fromWorkspaceId)) {
		storageForWorkspace = parsed.multiRoot.get(fromWorkspaceId);
	} else if (parsed.empty.has(fromWorkspaceId)) {
		storageForWorkspace = parsed.empty.get(fromWorkspaceId);
	} else if (parsed.folder.has(fromWorkspaceId)) {
		storageForWorkspace = parsed.folder.get(fromWorkspaceId);
	}

	// Migrate existing storage to new workspace id
	if (storageForWorkspace) {
		Object.keys(storageForWorkspace).forEach(key => {
			if (key === StorageService.WORKSPACE_IDENTIFIER) {
				return; // make sure to never migrate the workspace identifier
			}

			storage.setItem(`${StorageService.WORKSPACE_PREFIX}${newWorkspaceId}/${key}`, storageForWorkspace[key]);
		});
	}

	return newWorkspaceId;
}
开发者ID:AlexxNica,项目名称:sqlopsstudio,代码行数:28,代码来源:migration.ts

示例3: test

	test('getBackupResource should get the correct backup path for untitled files', () => {
		// Format should be: <backupHome>/<workspaceHash>/<scheme>/<filePath>
		const backupResource = Uri.from({ scheme: 'untitled', path: 'Untitled-1' });
		const workspaceHash = crypto.createHash('md5').update(workspaceResource.fsPath).digest('hex');
		const expectedPath = Uri.file(path.join(backupHome, workspaceHash, 'untitled', backupResource.fsPath)).fsPath;
		assert.equal(service.getBackupResource(backupResource).fsPath, expectedPath);
	});
开发者ID:,项目名称:,代码行数:7,代码来源:

示例4: test

	test('dirname', () => {
		const f = URI.file('/some/file/test.txt');
		const d = dirname(f);
		assert.equal(d.fsPath, normalize('/some/file', true));

		// does not explode (https://github.com/Microsoft/vscode/issues/41987)
		dirname(URI.from({ scheme: 'file', authority: '/users/someone/portal.h' }));
	});
开发者ID:burhandodhy,项目名称:azuredatastudio,代码行数:8,代码来源:resources.test.ts

示例5: test

	test('get encoded debug data', () => {
		const checkData = (uri: uri, expectedName, expectedPath, expectedSourceReference, expectedSessionId) => {
			let { name, path, sourceReference, sessionId } = Source.getEncodedDebugData(uri);
			assert.equal(name, expectedName);
			assert.equal(path, expectedPath);
			assert.equal(sourceReference, expectedSourceReference);
			assert.equal(sessionId, expectedSessionId);
		};

		checkData(uri.file('a/b/c/d'), 'd', normalize('/a/b/c/d', true), undefined, undefined);
		checkData(uri.from({ scheme: 'file', path: '/my/path/test.js', query: 'ref=1&session=2' }), 'test.js', normalize('/my/path/test.js', true), undefined, undefined);

		checkData(uri.from({ scheme: 'http', authority: 'www.msft.com', path: '/my/path' }), 'path', 'http://www.msft.com/my/path', undefined, undefined);
		checkData(uri.from({ scheme: 'debug', authority: 'www.msft.com', path: '/my/path', query: 'ref=100' }), 'path', '/my/path', 100, undefined);
		checkData(uri.from({ scheme: 'debug', path: 'a/b/c/d.js', query: 'session=100' }), 'd.js', 'a/b/c/d.js', undefined, 100);
		checkData(uri.from({ scheme: 'debug', path: 'a/b/c/d/foo.txt', query: 'session=100&ref=10' }), 'foo.txt', 'a/b/c/d/foo.txt', 10, 100);
	});
开发者ID:burhandodhy,项目名称:azuredatastudio,代码行数:17,代码来源:debugSource.test.ts

示例6: test

	test('http#toString, encode=FALSE', () => {
		assert.equal(URI.from({ scheme: 'http', authority: 'a-test-site.com', path: '/', query: 'test=true' }).toString(true), 'http://a-test-site.com/?test=true');
		assert.equal(URI.from({ scheme: 'http', authority: 'a-test-site.com', path: '/', query: '', fragment: 'test=true' }).toString(true), 'http://a-test-site.com/#test=true');
		assert.equal(URI.from({}).with({ scheme: 'http', path: '/api/files/test.me', query: 't=1234' }).toString(true), 'http:/api/files/test.me?t=1234');

		var value = URI.parse('file://shares/pröjects/c%23/#l12');
		assert.equal(value.authority, 'shares');
		assert.equal(value.path, '/pröjects/c#/');
		assert.equal(value.fragment, 'l12');
		assert.equal(value.toString(), 'file://shares/pr%C3%B6jects/c%23/#l12');
		assert.equal(value.toString(true), 'file://shares/pröjects/c%23/#l12');

		var uri2 = URI.parse(value.toString(true));
		var uri3 = URI.parse(value.toString());
		assert.equal(uri2.authority, uri3.authority);
		assert.equal(uri2.path, uri3.path);
		assert.equal(uri2.query, uri3.query);
		assert.equal(uri2.fragment, uri3.fragment);
	});
开发者ID:armanio123,项目名称:vscode,代码行数:19,代码来源:uri.test.ts

示例7: test

	test('Migrate Storage (empty => multi root)', () => {
		const workspaceToMigrateFrom = URI.from({ path: '1500007676869', scheme: 'empty' }).toString();
		createService(workspaceToMigrateFrom);

		const workspaceToMigrateTo = URI.from({ path: '2500007676869', scheme: 'root' }).toString();

		migrateStorageToMultiRootWorkspace(workspaceToMigrateFrom, { id: '2500007676869', configPath: null }, storage);

		const s2 = new StorageService(storage, storage, workspaceToMigrateTo);
		const parsed = parseStorage(storage);

		assert.equal(parsed.empty.size, 1);
		assert.equal(parsed.folder.size, 0);
		assert.equal(parsed.multiRoot.size, 1);

		const migratedStorage = parsed.multiRoot.get(workspaceToMigrateTo);
		assert.equal(Object.keys(migratedStorage).length, 4);
		assert.equal(migratedStorage['key1'], s2.get('key1', StorageScope.WORKSPACE));
		assert.equal(migratedStorage['key2.something'], s2.get('key2.something', StorageScope.WORKSPACE));
		assert.equal(migratedStorage['key3/special'], s2.get('key3/special', StorageScope.WORKSPACE));
		assert.equal(migratedStorage['key4 space'], s2.get('key4 space', StorageScope.WORKSPACE));
	});
开发者ID:AllureFer,项目名称:vscode,代码行数:22,代码来源:migration.test.ts

示例8: createMockModelService

export function createMockModelService(): IModelService {
	let contextService = new BaseWorkspaceContextService({
		resource: URI.from({ scheme: 'inmemory', authority: 'model', path: '/' }),
		id: null,
		name: null,
		uid: null,
		mtime: null
	}, {});

	let eventService = new EventService();

	let configurationService = new MockConfigurationService(contextService, eventService);

	return new MockModelService(null, configurationService, null);
}
开发者ID:AjuanM,项目名称:vscode,代码行数:15,代码来源:servicesTestUtils.ts

示例9: test

	test('URI#toString, user information in authority', () => {
		var value = URI.parse('http://foo:bar@localhost/far');
		assert.equal(value.toString(), 'http://foo:bar@localhost/far');

		value = URI.parse('http://foo@localhost/far');
		assert.equal(value.toString(), 'http://foo@localhost/far');

		value = URI.parse('http://foo:bAr@localhost:8080/far');
		assert.equal(value.toString(), 'http://foo:bAr@localhost:8080/far');

		value = URI.parse('http://foo@localhost:8080/far');
		assert.equal(value.toString(), 'http://foo@localhost:8080/far');

		value = URI.from({ scheme: 'http', authority: 'föö:bör@löcalhost:8080', path: '/far', query: undefined, fragment: undefined });
		assert.equal(value.toString(), 'http://f%C3%B6%C3%B6:b%C3%B6r@l%C3%B6calhost:8080/far');
	});
开发者ID:AllureFer,项目名称:vscode,代码行数:16,代码来源:uri.test.ts


注:本文中的vs/base/common/uri.from函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。