regexp: Unnecessary escapes of -

This commit is contained in:
Martin Aeschlimann 2021-11-12 16:22:32 +01:00
parent 4df57580d3
commit 8215e18557
No known key found for this signature in database
GPG key ID: 2609A01E695523E3
2 changed files with 3 additions and 3 deletions

View file

@ -678,8 +678,8 @@ function toCSSSelector(extensionId: string, path: string) {
let str = `${extensionId}-${path}`;
//remove all characters that are not allowed in css
str = str.replace(/[^_\-a-zA-Z0-9]/g, '-');
if (str.charAt(0).match(/[0-9\-]/)) {
str = str.replace(/[^_a-zA-Z0-9-]/g, '-');
if (str.charAt(0).match(/[0-9-]/)) {
str = '_' + str;
}
return str;

View file

@ -40,7 +40,7 @@ suite('Color Registry', function () {
const reqContext = await new RequestService(new TestConfigurationService(), environmentService, new NullLogService()).request({ url: 'https://raw.githubusercontent.com/microsoft/vscode-docs/vnext/api/references/theme-color.md' }, CancellationToken.None);
const content = (await asText(reqContext))!;
const expression = /\-\s*\`([\w\.]+)\`: (.*)/g;
const expression = /-\s*\`([\w\.]+)\`: (.*)/g;
let m: RegExpExecArray | null;
let colorsInDoc: { [id: string]: ColorInfo } = Object.create(null);