Merge pull request #138 from matrix-org/leniant-identifiers

Make identifier regexes closer to the spec
This commit is contained in:
Jorik Schellekens 2020-09-24 10:20:59 +01:00 committed by GitHub
commit ff62521614
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -16,13 +16,13 @@ import {
*/
type Verifier<A> = [RegExp, A];
export const roomVerifiers: Verifier<LinkKind.Alias | LinkKind.RoomId>[] = [
[/^#([^/:]+?):(.+)$/, LinkKind.Alias],
[/^!([^/:]+?):(.+)$/, LinkKind.RoomId],
[/^#([^:]*):(.+)$/, LinkKind.Alias],
[/^!([^:]*):(.+)$/, LinkKind.RoomId],
];
export const verifiers: Verifier<LinkKind>[] = [
[/^[!#]([^/:]+?):(.+?)\/\$([^/:]+?)$/, LinkKind.Permalink],
[/^@([^/:]+?):(.+)$/, LinkKind.UserId],
[/^\+([^/:]+?):(.+)$/, LinkKind.GroupId],
[/^[!#]([^:]*):(.+)\/\$([^:]+):(.+)$/, LinkKind.Permalink],
[/^@([^:]+):(.+)$/, LinkKind.UserId],
[/^\+([^:]+):(.+)$/, LinkKind.GroupId],
...roomVerifiers,
];