當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript posix.normalize方法代碼示例

本文整理匯總了TypeScript中vs/base/common/path.posix.normalize方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript posix.normalize方法的具體用法?TypeScript posix.normalize怎麽用?TypeScript posix.normalize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在vs/base/common/path.posix的用法示例。


在下文中一共展示了posix.normalize方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: test

	test('normalize', () => {
		assert.strictEqual(path.win32.normalize('./fixtures///b/../b/c.js'),
			'fixtures\\b\\c.js');
		assert.strictEqual(path.win32.normalize('/foo/../../../bar'), '\\bar');
		assert.strictEqual(path.win32.normalize('a//b//../b'), 'a\\b');
		assert.strictEqual(path.win32.normalize('a//b//./c'), 'a\\b\\c');
		assert.strictEqual(path.win32.normalize('a//b//.'), 'a\\b');
		assert.strictEqual(path.win32.normalize('//server/share/dir/file.ext'),
			'\\\\server\\share\\dir\\file.ext');
		assert.strictEqual(path.win32.normalize('/a/b/c/../../../x/y/z'), '\\x\\y\\z');
		assert.strictEqual(path.win32.normalize('C:'), 'C:.');
		assert.strictEqual(path.win32.normalize('C:..\\abc'), 'C:..\\abc');
		assert.strictEqual(path.win32.normalize('C:..\\..\\abc\\..\\def'),
			'C:..\\..\\def');
		assert.strictEqual(path.win32.normalize('C:\\.'), 'C:\\');
		assert.strictEqual(path.win32.normalize('file:stream'), 'file:stream');
		assert.strictEqual(path.win32.normalize('bar\\foo..\\..\\'), 'bar\\');
		assert.strictEqual(path.win32.normalize('bar\\foo..\\..'), 'bar');
		assert.strictEqual(path.win32.normalize('bar\\foo..\\..\\baz'), 'bar\\baz');
		assert.strictEqual(path.win32.normalize('bar\\foo..\\'), 'bar\\foo..\\');
		assert.strictEqual(path.win32.normalize('bar\\foo..'), 'bar\\foo..');
		assert.strictEqual(path.win32.normalize('..\\foo..\\..\\..\\bar'),
			'..\\..\\bar');
		assert.strictEqual(path.win32.normalize('..\\...\\..\\.\\...\\..\\..\\bar'),
			'..\\..\\bar');
		assert.strictEqual(path.win32.normalize('../../../foo/../../../bar'),
			'..\\..\\..\\..\\..\\bar');
		assert.strictEqual(path.win32.normalize('../../../foo/../../../bar/../../'),
			'..\\..\\..\\..\\..\\..\\');
		assert.strictEqual(
			path.win32.normalize('../foobar/barfoo/foo/../../../bar/../../'),
			'..\\..\\'
		);
		assert.strictEqual(
			path.win32.normalize('../.../../foobar/../../../bar/../../baz'),
			'..\\..\\..\\..\\baz'
		);
		assert.strictEqual(path.win32.normalize('foo/bar\\baz'), 'foo\\bar\\baz');

		assert.strictEqual(path.posix.normalize('./fixtures///b/../b/c.js'),
			'fixtures/b/c.js');
		assert.strictEqual(path.posix.normalize('/foo/../../../bar'), '/bar');
		assert.strictEqual(path.posix.normalize('a//b//../b'), 'a/b');
		assert.strictEqual(path.posix.normalize('a//b//./c'), 'a/b/c');
		assert.strictEqual(path.posix.normalize('a//b//.'), 'a/b');
		assert.strictEqual(path.posix.normalize('/a/b/c/../../../x/y/z'), '/x/y/z');
		assert.strictEqual(path.posix.normalize('///..//./foo/.//bar'), '/foo/bar');
		assert.strictEqual(path.posix.normalize('bar/foo../../'), 'bar/');
		assert.strictEqual(path.posix.normalize('bar/foo../..'), 'bar');
		assert.strictEqual(path.posix.normalize('bar/foo../../baz'), 'bar/baz');
		assert.strictEqual(path.posix.normalize('bar/foo../'), 'bar/foo../');
		assert.strictEqual(path.posix.normalize('bar/foo..'), 'bar/foo..');
		assert.strictEqual(path.posix.normalize('../foo../../../bar'), '../../bar');
		assert.strictEqual(path.posix.normalize('../.../.././.../../../bar'),
			'../../bar');
		assert.strictEqual(path.posix.normalize('../../../foo/../../../bar'),
			'../../../../../bar');
		assert.strictEqual(path.posix.normalize('../../../foo/../../../bar/../../'),
			'../../../../../../');
		assert.strictEqual(
			path.posix.normalize('../foobar/barfoo/foo/../../../bar/../../'),
			'../../'
		);
		assert.strictEqual(
			path.posix.normalize('../.../../foobar/../../../bar/../../baz'),
			'../../../../baz'
		);
		assert.strictEqual(path.posix.normalize('foo/bar\\baz'), 'foo/bar\\baz');
	});
開發者ID:PKRoma,項目名稱:vscode,代碼行數:69,代碼來源:path.test.ts


注:本文中的vs/base/common/path.posix.normalize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。