react-router-hono-server 4.1.9 → 4.1.10

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/http.d.ts CHANGED
@@ -17,5 +17,6 @@ export declare function redirect(c: Context, location: string): Response;
17
17
  * Get the current request path
18
18
  *
19
19
  * If the path ends with `.data` (React Router Single Fetch query), it will be removed.
20
+ * The `/_.data` suffix is normalized to `/` for root and trailing-slash routes.
20
21
  */
21
22
  export declare function getPath(c: Context): string;
package/dist/http.js CHANGED
@@ -44,15 +44,19 @@ function reactRouterRedirect(location) {
44
44
  * It follows the Single Fetch Redirect protocol, if the request path ends with `.data`.
45
45
  */
46
46
  function redirect(c, location) {
47
- if (c.req.path.includes(".data")) return reactRouterRedirect(location);
47
+ if (new URL(c.req.url).pathname.endsWith(".data")) return reactRouterRedirect(location);
48
48
  return c.redirect(location);
49
49
  }
50
50
  /**
51
51
  * Get the current request path
52
52
  *
53
53
  * If the path ends with `.data` (React Router Single Fetch query), it will be removed.
54
+ * The `/_.data` suffix is normalized to `/` for root and trailing-slash routes.
54
55
  */
55
56
  function getPath(c) {
56
- return c.req.path.replace(".data", "");
57
+ const pathname = new URL(c.req.url).pathname;
58
+ if (pathname.endsWith("/_.data")) return c.req.path.replace(/_\.data$/, "");
59
+ if (pathname.endsWith(".data")) return c.req.path.replace(/\.data$/, "");
60
+ return c.req.path;
57
61
  }
58
62
  export { getPath, reactRouterRedirect, redirect };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-router-hono-server",
3
- "version": "4.1.9",
3
+ "version": "4.1.10",
4
4
  "description": "The Vite plugin you need to create a Hono server for your React Router app in less than 10 seconds.",
5
5
  "homepage": "https://github.com/rphlmr/react-router-hono-server#readme",
6
6
  "bugs": {