@tmlmobilidade/fastify 20260625.1443.7 → 20260626.1034.45
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/fastify-service.js +16 -0
- package/package.json +1 -1
package/dist/fastify-service.js
CHANGED
|
@@ -213,6 +213,22 @@ export class FastifyService {
|
|
|
213
213
|
* Sets up hooks for the Fastify server including error handling and response processing.
|
|
214
214
|
*/
|
|
215
215
|
_setupHooks() {
|
|
216
|
+
/**
|
|
217
|
+
* Decodes URI-encoded `id` path params so encoded slashes (e.g. `%2F`) are
|
|
218
|
+
* available as literal characters in route handlers.
|
|
219
|
+
*/
|
|
220
|
+
this.server.addHook('preHandler', (request, _, done) => {
|
|
221
|
+
const params = request.params;
|
|
222
|
+
if (params.id !== undefined) {
|
|
223
|
+
try {
|
|
224
|
+
params.id = decodeURIComponent(params.id);
|
|
225
|
+
}
|
|
226
|
+
catch {
|
|
227
|
+
// Malformed URI sequence — keep original value
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
done();
|
|
231
|
+
});
|
|
216
232
|
/**
|
|
217
233
|
* Sets a global error handler for the Fastify server instance.
|
|
218
234
|
* This handler checks if the error is an instance of HttpException.
|