Skip to content

fix(filters): match multi-word character ids in include/exclude - #696

Open
DamianZamolski wants to merge 2 commits into
AdmiralGT:mainfrom
DamianZamolski:fix-character-id-space
Open

fix(filters): match multi-word character ids in include/exclude#696
DamianZamolski wants to merge 2 commits into
AdmiralGT:mainfrom
DamianZamolski:fix-character-id-space

Conversation

@DamianZamolski

Copy link
Copy Markdown

Problem

The include/exclude character filters silently match nothing for any multi-word character.

Example: excluding Snake Charmer (URL ?exclude=Snake+Charmer) still returns scripts containing the Snake Charmer.

Cause

name_to_id() in scripts/filters.py replaced spaces with underscores:

name.replace(" ", "_")  # "Snake Charmer" -> "snake_charmer"

But official character ids carry no separator (snakecharmer), so content__contains=[{"id": "snake_charmer"}] never matches. Single-word characters (e.g. mutant) worked only because they have no space.

Fix

Strip the space instead of underscoring it, so Snake Charmer -> snakecharmer.

Verified against dev/characters.json: all 172 official character ids match ^[a-z0-9]+$ (no spaces, underscores, or hyphens), so removing spaces is safe and correct for both include and exclude.

🤖 Generated with Claude Code

DamianZamolski and others added 2 commits August 5, 2026 12:03
name_to_id underscored spaces, but official ids have no
separator (snakecharmer, not snake_charmer), so include/exclude
silently matched nothing for multi-word characters.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Move name_to_id to script_json so it is importable without the
Django app registry (tests.settings is empty by design), then
add unit tests for the space/apostrophe/case normalisation.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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