Skip to content

fix: accept a resource query written as a string - #360

Merged
alexander-akait merged 1 commit into
mainfrom
fix/resource-query-exclude-types
Sep 14, 2026
Merged

alexander-akait merged 1 commit into
mainfrom
fix/resource-query-exclude-types

Conversation

@alexander-akait

Copy link
Copy Markdown
Member

Summary

The follow-up I said I would open from #353. Four places described resourceQueryExclude and no two agreed:

said
schema RegExp or an array of anything
JSDoc typedef RegExp | RegExp[] | string | string[]
README RegExp | RegExp[]
the code item instanceof RegExp ? item : new RegExp(item)

So ["media"] worked, "media" was refused by validation, and [42] passed validation and quietly became /42/.

The schema now says what the code does — a regexp, a string, or a list of either — and the README says it too. The typedef was already right.

Note the array's items is constrained where it was not before, so an entry that is neither is now a validation error rather than a silent coercion. Worth doing before 1.0.0 rather than after.

What kind of change does this PR introduce?

fix.

Did you add tests for your changes?

Yes — test/resource-query.test.js covers the string on its own, in a list, and mixed with a regexp, plus the rejection of a number. The first and last fail against the unmodified schema.

Does this PR introduce a breaking change?

No for anything documented or working. A configuration passing something that is neither a regexp nor a string in the array is now rejected at validation instead of being turned into a regexp of its string form; nothing documents that as supported, and the plugin has not released under this name.

If relevant, what needs to be documented once your changes are merged or what have you already documented?

Documented here — the type line and a sentence saying a string is read as the regexp's source.

Use of AI

AI was used. It found the disagreement while writing #353's test, reproduced each of the three behaviours, then made the schema and the README agree with the code and added the cases.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GzZci4NQeiqwdrVfd7dGXy


Generated by Claude Code

The schema, the type and the README each said something different about
`resourceQueryExclude`. The schema took a regexp or an array of anything,
the JSDoc took regexps and strings either way round, the README took
regexps only, and the code read a string as the source of a regexp. So
`["media"]` worked, `"media"` was refused by validation, and `[42]` was
accepted and quietly became `/42/`.

The schema now says what the code does — a regexp, a string, or a list of
either — and the README says it too.
@alexander-akait
alexander-akait merged commit db27ef1 into main Sep 14, 2026
15 checks passed
@alexander-akait
alexander-akait deleted the fix/resource-query-exclude-types branch September 14, 2026 15:24
This was referenced Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant