Skip to content

Commit 4d1a390

Browse files
robhoganmeta-codesync[bot]
authored andcommitted
Document the expected input/output of rewriteRequestUrl
Summary: [`rewriteRequestUrl`](https://metrobundler.dev/docs/configuration/#rewriterequesturl) usually receives paths (eg, from `req.url` when processing a request), but sometimes also absolute URLs (eg, when processing source URL in a symbolicate payload), and the returned value is expected to mirror the input. This just caught me out, so I'm clarifying in the docs. We should change this API. It's especially awkward now that Node's `url.parse` is deprecated. Changelog: Docs Reviewed By: vzaidman Differential Revision: D91132265 fbshipit-source-id: 49c2f1af79415ce3a8dcdd099a90c670db2cf721
1 parent ff58afb commit 4d1a390

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

docs/Configuration.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,13 @@ The `Middleware` type is an alias for [`connect.HandleFunction`](https://github.
643643
644644
Type: `string => string`
645645
646-
A function that will be called every time Metro processes a URL, after normalization of non-standard query-string delimiters using [`jsc-safe-url`](https://www.npmjs.com/package/jsc-safe-url). Metro will use the return value of this function as if it were the original URL provided by the client. This applies to all incoming HTTP requests (after any custom middleware), as well as bundle URLs in `/symbolicate` request payloads and within the hot reloading protocol.
646+
A function that will be called every time Metro processes a "URL" (see note), after normalization of non-standard query-string delimiters using [`jsc-safe-url`](https://www.npmjs.com/package/jsc-safe-url). Metro will use the return value of this function as if it were the original URL provided by the client. This applies to all incoming HTTP requests (after any custom middleware), as well as bundle URLs in `/symbolicate` request payloads and within the hot reloading protocol.
647+
648+
:::note
649+
650+
The input may be either an absolute URL (e.g. `https://example.com/foo/bar?baz=qux`) or a path (e.g. `/foo/bar?baz=qux`). The output should use the same form as the input - i.e. the returned value should be an absolute URL if and only if the input is an absolute URL.
651+
652+
:::
647653
648654
#### `forwardClientLogs`
649655

0 commit comments

Comments
 (0)