mirror of
https://github.com/Microsoft/vscode
synced 2024-07-17 02:57:19 +00:00
[css] requests update
This commit is contained in:
parent
cbb1610c12
commit
b49d4cf5e6
|
@ -113,9 +113,26 @@ export function basename(uri: string) {
|
||||||
return uri.substr(lastIndexOfSlash + 1);
|
return uri.substr(lastIndexOfSlash + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const Slash = '/'.charCodeAt(0);
|
const Slash = '/'.charCodeAt(0);
|
||||||
const Dot = '.'.charCodeAt(0);
|
const Dot = '.'.charCodeAt(0);
|
||||||
|
|
||||||
|
export function extname(uri: string) {
|
||||||
|
for (let i = uri.length - 1; i >= 0; i--) {
|
||||||
|
const ch = uri.charCodeAt(i);
|
||||||
|
if (ch === Dot) {
|
||||||
|
if (i > 0 && uri.charCodeAt(i - 1) !== Slash) {
|
||||||
|
return uri.substr(i);
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else if (ch === Slash) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
export function isAbsolutePath(path: string) {
|
export function isAbsolutePath(path: string) {
|
||||||
return path.charCodeAt(0) === Slash;
|
return path.charCodeAt(0) === Slash;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,7 @@
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
import 'mocha';
|
import 'mocha';
|
||||||
import * as assert from 'assert';
|
import * as assert from 'assert';
|
||||||
import { joinPath, normalizePath, resolvePath } from '../requests';
|
import { joinPath, normalizePath, resolvePath, extname } from '../requests';
|
||||||
|
|
||||||
|
|
||||||
suite('requests', () => {
|
suite('requests', () => {
|
||||||
test('join', async function () {
|
test('join', async function () {
|
||||||
|
@ -51,4 +50,13 @@ suite('requests', () => {
|
||||||
assertNormalize('..', '');
|
assertNormalize('..', '');
|
||||||
assertNormalize('/..', '/');
|
assertNormalize('/..', '/');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('extname', async function () {
|
||||||
|
function assertExtName(input: string, expected: string) {
|
||||||
|
assert.equal(extname(input), expected, input);
|
||||||
|
}
|
||||||
|
assertExtName('foo://a/foo/bar', '');
|
||||||
|
assertExtName('foo://a/foo/bar.foo', '.foo');
|
||||||
|
assertExtName('foo://a/foo/.foo', '');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue