@megabudino/stack-utils 2.3.0 → 2.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/proxy/handle.js +2 -0
- package/dist/proxy/rewrite.js +6 -5
- package/package.json +1 -1
package/dist/proxy/handle.js
CHANGED
|
@@ -98,6 +98,8 @@ export function createProxyHandle(config) {
|
|
|
98
98
|
cleanHeaders.delete('content-encoding');
|
|
99
99
|
cleanHeaders.delete('content-length');
|
|
100
100
|
cleanHeaders.delete('transfer-encoding');
|
|
101
|
+
cleanHeaders.delete('x-robots-tag');
|
|
102
|
+
cleanHeaders.delete('x-pingback');
|
|
101
103
|
if (isNullBodyStatus(upstreamResponse.status)) {
|
|
102
104
|
return new Response(null, {
|
|
103
105
|
status: upstreamResponse.status,
|
package/dist/proxy/rewrite.js
CHANGED
|
@@ -14,6 +14,12 @@ function domainPattern(siteUrl) {
|
|
|
14
14
|
* capturing the path portion (everything after the origin).
|
|
15
15
|
*/
|
|
16
16
|
function originPattern(origin) {
|
|
17
|
+
const schemeMatch = origin.match(/^https?:\/\//i);
|
|
18
|
+
if (schemeMatch) {
|
|
19
|
+
const rest = origin.slice(schemeMatch[0].length);
|
|
20
|
+
const escaped = rest.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
21
|
+
return new RegExp(`https?:\\/\\/${escaped}`, 'gi');
|
|
22
|
+
}
|
|
17
23
|
const escaped = origin.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
18
24
|
return new RegExp(escaped, 'gi');
|
|
19
25
|
}
|
|
@@ -39,11 +45,6 @@ export function rewriteHtml(html, originUrl, siteUrl, proxyAssets = false, addit
|
|
|
39
45
|
html = html.replace(originPattern(origin), '');
|
|
40
46
|
}
|
|
41
47
|
}
|
|
42
|
-
// SvelteKit origins emit relative `./_app/...` assets. Browsers resolve those to
|
|
43
|
-
// `/_app/...` on the proxy host, which collides with the local SvelteKit build.
|
|
44
|
-
// Point them at the origin so CSS/JS load from the upstream app (CORS permitting).
|
|
45
|
-
const originBase = originUrl.replace(/\/$/, '');
|
|
46
|
-
html = html.replace(/(["'(])\.\/_app\//g, `$1${originBase}/_app/`);
|
|
47
48
|
return html;
|
|
48
49
|
}
|
|
49
50
|
/** Normalize URL-like values to comparable sitemap pathnames. */
|