← Back to Pull requests

fix(url): canonicalize trailing-dot hosts in normalizePublicUrl #32

Closed
unknown closed this pull request without merging on Nov 25, 2026 09:34 UTC
View on GitHub
unknown unknown commented on Nov 25, 2026 09:19 UTC
Author

Bug


src/shared/url.ts validates host = url.hostname.toLowerCase().replace(/\.$/, ""), so localhost. and 127.0.0.1. are correctly rejected. But it then returned url.href with the original dotted host. So https://example.com./path passed validation and came back unchanged, and one site turned into two resource URLs. That splits permalinks and receipt url fields, and Wayback availability/CDX lookups key on the exact hostname, so they miss snapshots.

Fix


Set url.hostname = host before returning: one line.

Tests


src/shared/url.test.ts is new; the module had no direct tests. It covers:
  • canonical hrefs, default-port handling, and the trailing-dot case, which fails on main;

  • rejected forms: credentials, explicit ports, query strings, dotted/decimal/bracketed IPs, single-label hosts, local suffixes, CDX * wildcards and the length cap;

  • isGitHubRepository charset and length rules.
  • I ran it locally with a small vitest-compatible shim: 32/32 pass, and main fails exactly the trailing-dot case. CI runs the real vitest.
    <!-- devin-review-badge-begin -->

    ---

    <a href="https://app.devin.ai/review/mangeshraut712/gravekeeper/pull/32" target="_blank"><picture><source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-devin-review-dark.svg?v=4"><img src="https://static.devin.ai/assets/gh-devin-review-light.svg?v=4" alt="Devin Review"></picture></a>
    <!-- devin-review-badge-end -->

    <!-- CURSOR_SUMMARY -->
    ---

    [!NOTE]

    Low Risk

    Small behavioral fix in shared URL normalization with broad regression tests; aligns client and API signing without touching auth or persistence logic.

    > Overview

    Fixes normalizePublicUrl so validated hosts are returned without a trailing DNS root dot (https://example.com./path → https://example.com/path), and rejects hosts that still end with . after a single strip (e.g. example.com..).

    > Also adds src/shared/url.test.ts with Vitest coverage for canonicalization, idempotency, rejection rules, length limits, and isGitHubRepository validation.

    > <sup>Reviewed by Cursor Bugbot for commit c1cab49b42d5995dbc785d289058364335d0bf19. Bugbot is set up for automated code reviews on this repo. Configure here.</sup>

    <!-- /CURSOR_SUMMARY -->

    Diff: 295 lines (+221 / -74) across 3 files Reviewer: mangeshraut712 Review duration: 15m
    All Vouch review confidence checks passed
    Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 295 lines diff across 3 files
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.340
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #32"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 40.0% (MEDIUM) · Higher = larger blast radius
    40.0%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 15.8% · Safe to merge
    15.8%