Skip to content

Commit

Permalink
remove named groups in regex
Browse files Browse the repository at this point in the history
  • Loading branch information
pepoviola committed Aug 17, 2024
1 parent 01f88ba commit 164e67b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion javascript/packages/utils/src/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export function getFilePathNameExt(filePath: string): {

export function validateImageUrl(image: string): string {
const regex =
/^(?<Name>(?<=^)(?:(?<Domain>(?:(?:localhost|[\w-]+(?:\.[\w-]+)+)(?::\d+)?)|[\w]+:\d+)\/)?\/?(?<Namespace>(?:(?:[a-z0-9]+(?:(?:[._]|__|[-]*)[a-z0-9]+)*)\/)*)(?<Repo>[a-z0-9-]+))[:@]?(?<Reference>(?<=:)(?<Tag>[\w][\w.-]{0,127})|(?<=@)(?<Digest>[A-Za-z][A-Za-z0-9]*(?:[-_+.][A-Za-z][A-Za-z0-9]*)*[:][0-9A-Fa-f]{32,}))?/gm;
/^((?<=^)(?:((?:(?:localhost|[\w-]+(?:\.[\w-]+)+)(?::\d+)?)|[\w]+:\d+)\/)?\/?((?:(?:[a-z0-9]+(?:(?:[._]|__|[-]*)[a-z0-9]+)*)\/)*)([a-z0-9-]+))[:@]?((?<=:)([\w][\w.-]{0,127})|(?<=@)([A-Za-z][A-Za-z0-9]*(?:[-_+.][A-Za-z][A-Za-z0-9]*)*[:][0-9A-Fa-f]{32,}))?/gm;

if (!image.match(regex)) {
throw new Error("Image's URL is invalid: `" + image + "`");
Expand Down

0 comments on commit 164e67b

Please sign in to comment.