Adapt to valid characters for namespace and name

This commit is contained in:
René Pfeuffer
2020-07-01 11:17:28 +02:00
parent 8a0e0a3cc5
commit 19cf6be4c6

View File

@@ -28,12 +28,13 @@ import { Changeset } from "@scm-manager/ui-types";
import { Replacement } from "@scm-manager/ui-components";
const ChangesetShortLink: (changeset: Changeset, value: string) => Replacement[] = (changeset, value) => {
const matches = value.match(/(\w+)\/(\w+)@([a-f0-9]+)/g);
const linkRegExp = "([A-Za-z0-9\.\-_]+)\/([A-Za-z0-9\.\-_]+)@([a-f0-9]+)";
const matches = value.match(new RegExp(linkRegExp, "g"));
if (!matches) {
return [];
}
return matches.map(value => {
const groups = value.match(/(\w+)\/(\w+)@([a-f0-9]+)/);
const groups = value.match(new RegExp(linkRegExp));
const namespace = groups[1];
const name = groups[2];
const revision = groups[3];