Skip to content

Commit 0154a61

Browse files
committed
chore: rename option
1 parent 5074314 commit 0154a61

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

packages/server/src/api/rest/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,11 @@ export type Options = {
4747
idDivider?: string;
4848

4949
/**
50-
* The charset used for URL segment values. Defaults to `a-zA-Z0-9-_~ %`.
51-
* If the idDivider is set to a different value, it should be included in the charset.
50+
* The charset used for URL segment values. Defaults to `a-zA-Z0-9-_~ %`. You can change it if your entity's ID values
51+
* allow different characters. Specifically, if your models use compound IDs and the idDivider is set to a different value,
52+
* it should be included in the charset.
5253
*/
53-
urlSegmentNameCharset?: string;
54+
urlSegmentCharset?: string;
5455
};
5556

5657
type RelationshipInfo = {
@@ -219,7 +220,7 @@ class RequestHandler extends APIHandlerBase {
219220
constructor(private readonly options: Options) {
220221
super();
221222
this.idDivider = options.idDivider ?? prismaIdDivider;
222-
const segmentCharset = options.urlSegmentNameCharset ?? 'a-zA-Z0-9-_~ %';
223+
const segmentCharset = options.urlSegmentCharset ?? 'a-zA-Z0-9-_~ %';
223224
this.urlPatterns = this.buildUrlPatterns(this.idDivider, segmentCharset);
224225
}
225226

packages/server/tests/api/rest.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2554,7 +2554,7 @@ describe('REST server tests', () => {
25542554
endpoint: 'http://localhost/api',
25552555
pageSize: 5,
25562556
idDivider,
2557-
urlSegmentNameCharset: 'a-zA-Z0-9-_~ %@.:',
2557+
urlSegmentCharset: 'a-zA-Z0-9-_~ %@.:',
25582558
});
25592559
handler = (args) =>
25602560
_handler({ ...args, zodSchemas, modelMeta, url: new URL(`http://localhost/${args.path}`) });

0 commit comments

Comments
 (0)