fix: accept a resource query written as a string - #360
Merged
Merged
Conversation
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.
This was referenced Sep 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The follow-up I said I would open from #353. Four places described
resourceQueryExcludeand no two agreed:RegExpor an array of anythingRegExp | RegExp[] | string | string[]RegExp | RegExp[]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
itemsis 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.jscovers 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