@anthusai/papyrus 5.121.0-next.1 → 5.121.0
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.
|
@@ -124,6 +124,11 @@ function queryStringOf(request) {
|
|
|
124
124
|
return parts.length === 0 ? "" : "?" + parts.join("&");
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
+
// A redirect keeps the request's query string (a path on this site only: an absolute target is the rule's own address).
|
|
128
|
+
function withQuery(target, request) {
|
|
129
|
+
return target.charAt(0) === "/" && target.indexOf("?") === -1 ? target + queryStringOf(request) : target;
|
|
130
|
+
}
|
|
131
|
+
|
|
127
132
|
function wwwRedirectResponse(request) {
|
|
128
133
|
const header = request.headers && request.headers.host;
|
|
129
134
|
const host = header && header.value ? header.value.toLowerCase() : "";
|
|
@@ -150,7 +155,7 @@ async function handler(event) {
|
|
|
150
155
|
return {
|
|
151
156
|
statusCode: 301,
|
|
152
157
|
statusDescription: "Moved Permanently",
|
|
153
|
-
headers: { location: { value: redirectTarget } },
|
|
158
|
+
headers: { location: { value: withQuery(redirectTarget, request) } },
|
|
154
159
|
};
|
|
155
160
|
}
|
|
156
161
|
const patternRedirect = lookUpPatternRedirect(request.uri);
|
|
@@ -158,7 +163,7 @@ async function handler(event) {
|
|
|
158
163
|
return {
|
|
159
164
|
statusCode: patternRedirect.status,
|
|
160
165
|
statusDescription: "Moved",
|
|
161
|
-
headers: { location: { value: patternRedirect.target } },
|
|
166
|
+
headers: { location: { value: withQuery(patternRedirect.target, request) } },
|
|
162
167
|
};
|
|
163
168
|
}
|
|
164
169
|
request.uri = rewriteToIndexDocument(request.uri);
|
package/package.json
CHANGED
package/routes.manifest.json
CHANGED