@cloudflare/pages-shared 0.3.0 → 0.3.1

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.
@@ -204,16 +204,7 @@ export async function generateHandler<
204
204
  staticRedirectsMatcher() || generateRedirectsMatcher()({ request })[0];
205
205
 
206
206
  if (match) {
207
- if (match.status === 200) {
208
- // A 200 redirect means that we are proxying to a different asset, for example,
209
- // a request with url /users/12345 could be pointed to /users/id.html. In order to
210
- // do this, we overwrite the pathname, and instead match for assets with that url,
211
- // and importantly, do not use the regular redirect handler - as the url visible to
212
- // the user does not change
213
- pathname = new URL(match.to, request.url).pathname;
214
- } else {
215
- return getResponseFromMatch(match, url);
216
- }
207
+ return getResponseFromMatch(match, url);
217
208
  }
218
209
 
219
210
  if (!request.method.match(/^(get|head)$/i)) {
@@ -3,7 +3,7 @@ export const HEADERS_VERSION = 2;
3
3
  export const ANALYTICS_VERSION = 1;
4
4
  export const ROUTES_JSON_VERSION = 1;
5
5
 
6
- export const PERMITTED_STATUS_CODES = new Set([200, 301, 302, 303, 307, 308]);
6
+ export const PERMITTED_STATUS_CODES = new Set([301, 302, 303, 307, 308]);
7
7
  export const HEADER_SEPARATOR = ":";
8
8
  export const MAX_LINE_LENGTH = 2000;
9
9
  export const MAX_HEADER_RULES = 100;
@@ -104,7 +104,7 @@ export function parseRedirects(input: string): ParsedRedirects {
104
104
  invalid.push({
105
105
  line,
106
106
  lineNumber: i + 1,
107
- message: `Valid status codes are 200, 301, 302 (default), 303, 307, or 308. Got ${str_status}.`,
107
+ message: `Valid status codes are 301, 302 (default), 303, 307, or 308. Got ${str_status}.`,
108
108
  });
109
109
  continue;
110
110
  }
@@ -119,22 +119,6 @@ export function parseRedirects(input: string): ParsedRedirects {
119
119
  }
120
120
  seen_paths.add(from);
121
121
 
122
- if (status === 200) {
123
- // Error can only be that it's not relative - given validateUrl is called above without onlyRelative:true,
124
- // so if it's present, we can error to the user that proxying only expects relative urls
125
- const [proxyTo, error] = validateUrl(to, true, true, true);
126
- if (error) {
127
- invalid.push({
128
- line,
129
- lineNumber: i + 1,
130
- message: `Proxy (200) redirects can only point to relative paths. Got ${to}`,
131
- });
132
- continue;
133
- }
134
- rules.push({ from, to: proxyTo as string, status, lineNumber: i + 1 });
135
- continue;
136
- }
137
-
138
122
  rules.push({ from, to, status, lineNumber: i + 1 });
139
123
  }
140
124
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudflare/pages-shared",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/cloudflare/workers-sdk.git",