Skip to content

fix(core,schema,runtime): resolve international currencies, URI regexes, price formatting, SPA hash UTMs, attribute escaping, and unicode whitespace - #32

Merged
Adnan9-63 merged 1 commit into
mainfrom
fix/core-schema-runtime-parity-enhancements
Nov 17, 2026
Merged

Adnan9-63 merged 1 commit into
mainfrom
fix/core-schema-runtime-parity-enhancements

Conversation

@Adnan9-63

Copy link
Copy Markdown
Member

Summary of Changes

This pull request resolves 6 key open issues across @agentlens/core, @agentlens/schema, and @agentlens/runtime, significantly enhancing cross-border e-commerce accuracy, entity registry corroboration, single-page application (SPA) AI arrival detection, and DOM safety.

1. Fix #15: Broaden International Currency Recognition (@agentlens/core)

  • Expanded currency symbol recognition ([$₹€£¥₩₪₫฿], zł, kr, R$, CHF) and top ISO 4217 3-letter currency codes (USD, EUR, GBP, INR, CAD, AUD, JPY, CHF, BRL, CNY, SEK, NOK, KRW, NZD, SGD, HKD, PLN, ZAR, TRY, ILS).
  • Updated CURRENCY_REGEX in quotability.ts and CURRENCY_OR_NUMERIC_REGEX and tokenizeWords in differ.ts.
  • Verified in packages/core/test/core.test.ts.

2. Fix #16: Alternate Wikidata and Multilingual Wikipedia URIs (@agentlens/schema)

  • Updated WIKIDATA_URI_REGEX to accept canonical Wikidata entity formats (https://wikidata.org/entity/Q..., /wiki/Q..., http://).
  • Updated WIKIPEDIA_URI_REGEX to support multilingual and regional subdomains (simple.wikipedia.org, zh-classical.wikipedia.org, fr.wikipedia.org).
  • Added exhaustive validation tests in packages/schema/test/schema.test.ts.

3. Fix #18: Normalized Price Matching in JSON-LD Parity Checks (@agentlens/core)

  • Implemented isPricePresentInText() in jsonld.ts to normalize prices with thousands separators ($1,250), decimals ($1,250.00, $249), European dot separators (1.250 €), and Scandinavian spaces (1 250 kr).
  • Eliminates false positive point deductions on e-commerce product pages with formatted pricing displays.
  • Added comprehensive unit tests in packages/core/test/core.test.ts.

4. Fix #20: SPA Hash Route AI Arrival & UTM Detection (@agentlens/runtime)

  • Updated detectExplicitReferrer() to inspect window.location.hash for query strings when window.location.search is empty (e.g. /#/product?utm_source=perplexity.ai).
  • Fixed a domain-priority bug where generic utm_medium=ai-search previously overrode specific utm_source matches.
  • Added unit tests in packages/runtime/test/runtime.test.ts.

5. Fix #21: Single-Quote Sanitization & Selector Escaping (@agentlens/runtime)

  • Expanded escapeHtml() to sanitize single quotes (') as '.
  • Escaped data-agent-section values using replace(/["\\]/g, '\\$&') before building attribute selectors.
  • Wrapped dynamic document.querySelector() lookups in try/catch to gracefully tolerate malformed selectors.
  • Added unit tests in packages/runtime/test/runtime.test.ts.

6. Fix #23: Unicode Whitespace & Non-Breaking Space Normalization (@agentlens/schema)

  • Normalized non-breaking spaces (\u00A0), thin spaces (\u2009), em spaces (\u2003), and zero-width joiners in countWords() and startsWithBarePronoun().
  • Prevents word-count skewing on internationalized and CMS-rendered copy.
  • Added unit tests in packages/schema/test/schema.test.ts.

Verification & Test Results

  • Turborepo Workspace Build: 11/11 tasks passed cleanly
  • Strict TypeScript Check: 8/8 tasks passed with 0 errors (pnpm check-types)
  • Unit Test Coverage: 44 passing tests across all packages (up from 38)
    • @agentlens/core: 19 passed
    • @agentlens/schema: 11 passed
    • @agentlens/runtime: 6 passed
    • agentlens (CLI): 5 passed
    • @agentlens/mcp: 3 passed

Fixes #15
Fixes #16
Fixes #18
Fixes #20
Fixes #21
Fixes #23

…es, price formatting, SPA hash UTMs, attribute escaping, and unicode whitespace
Copilot AI balanced review requested due to automatic review settings November 17, 2026 09:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@Adnan9-63
Adnan9-63 merged commit 91dd6fa into main Nov 17, 2026
13 checks passed
@Adnan9-63
Adnan9-63 deleted the fix/core-schema-runtime-parity-enhancements branch November 17, 2026 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants