Skip to content

Centralize link key normalization logic to @dub/utils #3906

@ANU-2524

Description

@ANU-2524

Currently, the logic for processing and normalizing link keys (handling case-sensitivity, + for inspection, and punycode) is duplicated across several files. This creates maintenance overhead and potential inconsistencies between the redirect middleware and the API.

Files to address:

apps/web/lib/middleware/link.ts
apps/web/lib/api/links/utils/process-key.ts

Proposed Solution:

  1. Extract the normalization logic into a pure function in packages/utils.
  2. This function should handle:
  • punycode encoding/decoding.
  • Case normalization based on the domain's caseSensitive setting.
  • Stripping the + suffix used for info pages.
  1. Update all call sites to use this shared utility.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions