sst 2.36.7 → 2.36.8

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.
@@ -28,38 +28,34 @@ export class AstroSite extends SsrSite {
28
28
  return JSON.parse(readFileSync(filePath, "utf-8"));
29
29
  }
30
30
  static getCFRoutingFunction({ routes, pageResolution, }) {
31
- const serializedRoutes = "[\n" +
32
- routes
33
- .map((route) => {
34
- return ` {route: "${route.route}", pattern: ${route.pattern}, type: "${route.type}", ${typeof route.prerender !== "undefined"
35
- ? `prerender: ${route.prerender}, `
36
- : ``}${route.redirectPath ? `redirectPath: "${route.redirectPath}", ` : ""}${route.redirectStatus
37
- ? `redirectStatus: ${route.redirectStatus}`
38
- : ""} }`;
39
- })
40
- .join(",\n") +
41
- "\n ]";
42
- return ` // AstroSite CF Routing Function
43
- var astroRoutes = ${serializedRoutes};
44
- var matchedRoute = astroRoutes.find((route) => route.pattern.test(request.uri));
45
- if (matchedRoute) {
46
- if (matchedRoute.type === "redirect") {
47
- var redirectPath = matchedRoute.redirectPath;
48
- matchedRoute.pattern.exec(request.uri).forEach((match, index) => {
49
- redirectPath = redirectPath.replace(\`\\\${\${index}}\`, match);
31
+ const serializedRoutes = routes.map((route) => ({
32
+ rt: route.route,
33
+ pt: route.pattern,
34
+ t: route.type,
35
+ pr: route.prerender === true ? true : undefined,
36
+ rp: route.redirectPath,
37
+ rs: route.redirectStatus,
38
+ }));
39
+ return `
40
+ var routes = ${JSON.stringify(serializedRoutes)}
41
+ var match = routes.find((route) => new RegExp(route.pt).test(request.uri));
42
+ if (match) {
43
+ if (match.t === "redirect") {
44
+ var redirectPath = match.rp;
45
+ new RegExp(match.pt).exec(request.uri)?.forEach((match, index) => {
46
+ redirectPath = redirectPath.replace(\`\\\${\${index}}\`, match)
50
47
  });
51
- var statusCode = matchedRoute.redirectStatus || 308;
52
48
  return {
53
- statusCode,
49
+ statusCode: match.rs || 308,
54
50
  headers: { location: { value: redirectPath } },
55
51
  };
56
- } else if (matchedRoute.type === "page" && matchedRoute.prerender) {
52
+ } else if (match.t === "page" && match.pr) {
57
53
  ${pageResolution === "file"
58
54
  ? `request.uri = request.uri === "/" ? "/index.html" : request.uri.replace(/\\/?$/, ".html");`
59
55
  : `request.uri = request.uri.replace(/\\/?$/, "/index.html");`}
60
56
  }
61
57
  }
62
- // End AstroSite CF Routing Function`;
58
+ `;
63
59
  }
64
60
  plan() {
65
61
  const { path: sitePath } = this.props;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "sideEffects": false,
3
3
  "name": "sst",
4
- "version": "2.36.7",
4
+ "version": "2.36.8",
5
5
  "bin": {
6
6
  "sst": "cli/sst.js"
7
7
  },
@@ -120,7 +120,7 @@
120
120
  "@types/ws": "^8.5.3",
121
121
  "@types/yargs": "^17.0.13",
122
122
  "archiver": "^5.3.1",
123
- "astro-sst": "2.36.7",
123
+ "astro-sst": "2.36.8",
124
124
  "async": "^3.2.4",
125
125
  "tsx": "^3.12.1",
126
126
  "typescript": "^5.2.2",