Skip to content

Commit ec0f2b5

Browse files
authored
Provide additional guarantees about web-features identifiers (#2974)
Fixes #2973.
1 parent 506b496 commit ec0f2b5

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

docs/guidelines.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Feature authors should (in descending order of priority):
6262

6363
A feature's identifier is the feature's filename before the `.yml` extension.
6464

65-
Feature identifiers must contain only lowercase alphanumeric characters (a-z and 0-9) plus the `-` character (hyphen or minus sign) as a word separator.
65+
Feature identifiers must start with a lowercase alphabetic character (a-z) and contain only lowercase alphanumeric characters (a-z and 0-9) plus the `-` character (hyphen or minus sign) as a word separator.
6666

6767
The identifier should match the name, with these additional guidelines:
6868

index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ const descriptionMaxLength = 300;
2525
// of a draft directory doesn't work.
2626
const draft = Symbol('draft');
2727

28-
const identifierPattern = /^[a-z0-9-]*$/;
28+
// This must match the definition in docs/guidelines.md
29+
const identifierPattern = /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;
2930

3031
function* yamlEntries(root: string): Generator<[string, any]> {
3132
const filePaths = new fdir()
@@ -39,7 +40,7 @@ function* yamlEntries(root: string): Generator<[string, any]> {
3940
const { name: key } = path.parse(fp);
4041

4142
if (!identifierPattern.test(key)) {
42-
throw new Error(`${key} is not a valid identifier (must be lowercase a-z, 0-9, and hyphens)`);
43+
throw new Error(`${key} is not a valid identifier (see guidelines)`);
4344
}
4445

4546
const data = YAML.parse(fs.readFileSync(fp, { encoding: 'utf-8'}));

0 commit comments

Comments
 (0)