Skip to content

Commit b3246da

Browse files
committed
Fix verifyChanges() pathPrefix option
I got the precedence of `??` incorrect 4 years ago in 13dd38d. This didn't let any truthy string value given to take effect. In reality, I was trying to allow strings or nulls through and default only for the undefined case.
1 parent b79a0eb commit b3246da

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/components/authorization/policy/executor/resource-privileges.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,16 +168,18 @@ export class ResourcePrivileges<TResourceStatic extends ResourceShape<any>> {
168168
verifyChanges(
169169
changes: AnyChangesOf<TResourceStatic['prototype']>,
170170
{
171-
pathPrefix: pathPrefixProp,
171+
pathPrefix,
172172
}: {
173173
pathPrefix?: string | null;
174174
} = {},
175175
) {
176-
const pathPrefix =
177-
pathPrefixProp ?? pathPrefixProp === null
178-
? null
179-
: // Guess the input field path based on name convention
180-
startCase(this.resource.name).split(' ').at(-1)!.toLowerCase();
176+
if (pathPrefix === undefined) {
177+
// Guess the input field path based on name convention
178+
pathPrefix = startCase(this.resource.name)
179+
.split(' ')
180+
.at(-1)!
181+
.toLowerCase();
182+
}
181183

182184
for (const prop of Object.keys(changes)) {
183185
const dtoPropName: any = isRelation(this.resource, prop)

0 commit comments

Comments
 (0)