Make identifier regexes closer to the spec

This commit is contained in:
Jorik Schellekens 2020-09-23 11:32:41 +01:00
parent 75476bce86
commit 78f8bfb45d

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,
];