Skip to content

Commit

Permalink
fix parsing of custom buildpack urls (#3713)
Browse files Browse the repository at this point in the history
  • Loading branch information
Feroze Mohideen authored Oct 3, 2023
1 parent a5e3736 commit 07c65ab
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ function isValidBuildpack(url: string): boolean {
if (url.startsWith(urnPrefix)) {
return true;
}

const pattern = /^(https?:\/\/)?([\w.-]+)\.([a-z]{2,})(:\d{2,5})?([\/\w.-]*)*\/?$/i;
return pattern.test(url);
try {
new URL(url);
return true;
} catch (error) {
return false;
}
}

const AddCustomBuildpackComponent: React.FC<{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ function isValidBuildpack(url: string): boolean {
if (url.startsWith(urnPrefix)) {
return true;
}

const pattern = /^(https?:\/\/)?([\w.-]+)\.([a-z]{2,})(:\d{2,5})?([\/\w.-]*)*\/?$/i;
return pattern.test(url);
try {
new URL(url);
return true;
} catch (error) {
return false;
}
}

const AddCustomBuildpack: React.FC<{
Expand Down Expand Up @@ -53,7 +56,7 @@ const AddCustomBuildpack: React.FC<{
</EventInformation>
</ContentContainer>
<ActionContainer>
<ActionButton onClick={() => handleAddCustomBuildpack()}>
<ActionButton onClick={() => handleAddCustomBuildpack()} type="button">
<span className="material-icons-outlined">add</span>
</ActionButton>
</ActionContainer>
Expand Down

0 comments on commit 07c65ab

Please sign in to comment.