Skip to content

feat: add SensitiveParsers preset with protocol-qualified URL support - #8

Draft
ClaudiuCeia with Copilot wants to merge 3 commits into
mainfrom
copilot/mod-consider-adding-urls-to-piiparsers
Draft

feat: add SensitiveParsers preset with protocol-qualified URL support#8
ClaudiuCeia with Copilot wants to merge 3 commits into
mainfrom
copilot/mod-consider-adding-urls-to-piiparsers

Conversation

Copilot AI commented Jul 25, 2026

Copy link
Copy Markdown

PIIParsers excludes URLs entirely, even though protocol-qualified URLs routinely carry reset tokens, signed parameters, and credentials. Adding URL.parser wholesale would also redact innocent bare domains — so this introduces a separate, broader preset instead.

Changes

  • mod.ts — two new exports:
    • SensitiveEntity = PIIEntity | URLEntity
    • SensitiveParsers — all 12 PII parsers + dot(URL.Full) (protocol-qualified URLs only; bare domains like example.com are intentionally not matched)
  • docs/src/registry.tsSENSITIVE_IDS constant (PII_IDS + "URL") for future playground wiring
  • tests/redact.test.ts — 5 new tests: full-URL redaction, bare-domain passthrough, PII+URL combo, mixed bare+full in one input, and a compile-time type membership assertion

PIIParsers / PIIEntity are unchanged.

import { Duckling, SensitiveParsers } from "@claudiu-ceia/ts-duckling";

Duckling(SensitiveParsers).redact(
  "Reset: https://example.com/reset?token=abc123  — visit docs.example.com",
);
// → "Reset: ██████████████████████████████████████████  — visit docs.example.com"

Introduces `SensitiveEntity` type and `SensitiveParsers` parser tuple that
extend the PII preset with protocol-qualified URLs (https/http/ftp) while
intentionally excluding bare domains (e.g. `example.com`).

- `PIIParsers` / `PIIEntity` are unchanged (direct identifiers only)
- `SensitiveParsers` uses `dot(URL.Full)` — full URLs only, not bare domains
- `SensitiveEntity = PIIEntity | URLEntity`
- Playground registry gets `SENSITIVE_IDS` for future UI wiring
- 5 new tests: full-URL redaction, bare-domain passthrough, PII+URL combo,
  mixed bare+full, and a compile-time type membership assertion

Closes #7
Copilot AI changed the title [WIP] Consider adding URLs to PIIParsers for better sensitivity handling feat: add SensitiveParsers preset with protocol-qualified URL support Jul 25, 2026
Copilot AI requested a review from ClaudiuCeia July 25, 2026 13:16
@ClaudiuCeia

Copy link
Copy Markdown
Owner

@copilot - what's going on here

Copilot AI commented Jul 25, 2026

Copy link
Copy Markdown
Author

@copilot - what's going on here

This PR resolves #7 by adding a SensitiveParsers preset and SensitiveEntity type to complement the existing PIIParsers/PIIEntity.

The problem: PIIParsers intentionally omits URLs, but protocol-qualified URLs (e.g. https://example.com/reset?token=abc123) routinely carry sensitive data. Adding URL.parser wholesale would also redact innocent bare domains (example.com), which is undesirable.

The solution: a separate, broader preset that uses dot(URL.Full) — the existing URL.Full sub-parser — which matches only protocol-qualified URLs (https://, http://, ftp://), not bare domains:

Duckling(SensitiveParsers).redact(
  "Reset: https://example.com/reset?token=abc123  — visit docs.example.com",
);
// → "Reset: ██████████████████████████████████████████  — visit docs.example.com"

PIIParsers / PIIEntity are untouched. The SENSITIVE_IDS addition to docs/src/registry.ts is a forward-looking constant for playground UI wiring (no UI changes in this PR).

@ClaudiuCeia

Copy link
Copy Markdown
Owner

@copilot - I was talking about the CI failure. Also, are you taking this out of draft when done?

Copilot AI commented Jul 25, 2026

Copy link
Copy Markdown
Author

@copilot - I was talking about the CI failure. Also, are you taking this out of draft when done?

The CI failure was a deno fmt violation — the import block in tests/redact.test.ts had type PIIEntity before Phone, but the formatter expects Phone first (case-insensitive alphabetical order). Fixed in the latest commit.

Regarding taking it out of draft — I'm not able to change the PR state directly, but everything should be ready for review now.

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.

mod: consider adding URLs to PIIParsers (or a SensitiveParsers preset)

2 participants