Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
wirednkod committed Nov 3, 2023
2 parents d523517 + 115711f commit 8dad9ae
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions javascript/packages/utils/src/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,8 @@ export function getFilePathNameExt(filePath: string): {
}

export function validateImageUrl(image: string): string {
// const ipRegexStr =
// "((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))";
// const hostnameRegexStr =
// "((([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]).)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9]))";
// const tagNameRegexStr = "([a-z0-9](-*[a-z0-9])*)";
// const tagVersionRegexStr = "([a-z0-9_]([-._a-z0-9])*)";
// const RepoTagRegexStr = `^(${ipRegexStr}|${hostnameRegexStr}/)?${tagNameRegexStr}(:${tagVersionRegexStr})?$`;

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;
/^(?<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;

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

0 comments on commit 8dad9ae

Please sign in to comment.