Skip to content

Commit

Permalink
fix: allow - in hostnames for Netlify Image CDN (#388)
Browse files Browse the repository at this point in the history
* fix: allow `-` in hostnames for Netlify Image CDN RegEx

* Update orange-countries-scream.md

---------

Co-authored-by: Matt Kane <[email protected]>
  • Loading branch information
hrishikesh-k and ascorbic authored Sep 11, 2024
1 parent 53625d5 commit 3f280f1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/orange-countries-scream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/netlify': patch
---

Allows `-` in hostnames for Netlify Image CDN RegEx
4 changes: 2 additions & 2 deletions packages/netlify/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ export function remotePatternToRegex(
if (hostname) {
if (hostname.startsWith('**.')) {
// match any number of subdomains
regexStr += '([a-z0-9]+\\.)*';
regexStr += '([a-z0-9-]+\\.)*';
hostname = hostname.substring(3);
} else if (hostname.startsWith('*.')) {
// match one subdomain
regexStr += '([a-z0-9]+\\.)?';
regexStr += '([a-z0-9-]+\\.)?';
hostname = hostname.substring(2); // Remove '*.' from the beginning
}
// Escape dots in the hostname
Expand Down

0 comments on commit 3f280f1

Please sign in to comment.