Skip to content

Support SPDX IDs with dots in license URL slugs#220

Open
mlaetitia wants to merge 2 commits intodevelopfrom
fix/T51ENG-1496-spdx-dots-in-slugs
Open

Support SPDX IDs with dots in license URL slugs#220
mlaetitia wants to merge 2 commits intodevelopfrom
fix/T51ENG-1496-spdx-dots-in-slugs

Conversation

@mlaetitia
Copy link
Collaborator

@mlaetitia mlaetitia commented Mar 13, 2026

Related to T51ENG-1496

Proposed changes

  • Add dot-preservation for license post slugs (SPDX identifiers like Apache-2.0, GPL-3.0) across three layers: save-time (wp_insert_post_data, wp_unique_post_slug), query-time (sanitize_title filter with cached DB lookup), and REST API route regex.
  • Add Gutenberg editor script that prevents cleanForSlug from stripping dots — handles both title-driven slug generation (wp.data.subscribe) and manual slug edits (capture-phase focusout listener).
  • Fix negative cache lookup bug where false was indistinguishable from a cache miss.

Why are these changes being made?

WordPress sanitize_title strips dots from slugs by default. SPDX license identifiers use dots as version separators (e.g.,Apache-2.0), so license URLs were being mangled to /license/apache-2-0 instead of the canonical /license/apache-2.0. This caused SEO issues and broken links from external sources using the standard SPDX identifiers. The previous approach used the Redirection plugin which created conflicting canonical signals.

Testing instructions

  • Create a new license post with title Apache-2.0 — slug should auto-generate as apache-2.0 (not apache-2-0)
  • Edit an existing license post's slug to include dots (e.g., mit-1.0) — dots should persist after clicking away (brief visual
    flicker is expected)
  • Visit /license/apache-2.0 on the front end — should resolve to the correct license post
  • Visit /osi/v1/license/apache-2.0 REST endpoint — should return the license data
  • Verify non-dotted license slugs (e.g., MIT) still work normally
  • Verify other post types are unaffected by the sanitize_title filter

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