Skip to content

Commit 9f621ec

Browse files
committed
fix: only rewrite url for proper helix hosts
1 parent 867ff1b commit 9f621ec

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/steps/utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const AZURE_BLOB_REGEXP = /^https:\/\/hlx\.blob\.core\.windows\.net\/external\//
1414

1515
const MEDIA_BLOB_REGEXP = /^https:\/\/.*\.(aem|hlx3?)\.(live|page)\/media_.*/;
1616

17-
const HELIX_URL_REGEXP = /^https:\/\/(?!admin\.|www\.)[^.]+\.(aem|hlx3?)\.(live|page)\/?.*/;
17+
const HELIX_URL_REGEXP = /^https:\/\/.*\.(aem|hlx3?)\.(live|page)\/?.*/;
1818

1919
/**
2020
* Returns the original host name from the request to the outer CDN.
@@ -208,7 +208,7 @@ export function rewriteUrl(state, url) {
208208
return `.${pathname}${hash}`;
209209
}
210210

211-
if (HELIX_URL_REGEXP.test(url)
211+
if ((host.includes('--') && HELIX_URL_REGEXP.test(url))
212212
|| host === state.previewHost
213213
|| host === state.liveHost) {
214214
if (hash && pathname === state.info?.path) {

test/steps/utils.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ describe('Rewrite URLs test', () => {
163163
it('keeps helix urls for www and admin in place', () => {
164164
assert.strictEqual(rewriteUrl({}, 'https://www.hlx.page/docs'), 'https://www.hlx.page/docs');
165165
assert.strictEqual(rewriteUrl({}, 'https://www.aem.live/docs'), 'https://www.aem.live/docs');
166+
assert.strictEqual(rewriteUrl({}, 'https://tools.aem.live/docs'), 'https://tools.aem.live/docs');
166167
assert.strictEqual(rewriteUrl({}, 'https://admin.hlx.live/api'), 'https://admin.hlx.live/api');
167168
});
168169

0 commit comments

Comments
 (0)