From 164e67bd446ff9dc435e2716ed154b06a165f668 Mon Sep 17 00:00:00 2001 From: Javier Viola Date: Sat, 17 Aug 2024 12:41:04 -0300 Subject: [PATCH] remove named groups in regex --- javascript/packages/utils/src/misc.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/javascript/packages/utils/src/misc.ts b/javascript/packages/utils/src/misc.ts index 45326b186..89d88338f 100644 --- a/javascript/packages/utils/src/misc.ts +++ b/javascript/packages/utils/src/misc.ts @@ -155,7 +155,7 @@ export function getFilePathNameExt(filePath: string): { export function validateImageUrl(image: string): string { const regex = - /^(?(?<=^)(?:(?(?:(?: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; + /^((?<=^)(?:((?:(?: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 + "`");