From d82d908bc2b963dff58baa86ff2eeaa850eb78ea Mon Sep 17 00:00:00 2001
From: maruson08
Date: Wed, 7 Oct 2026 15:41:28 +0900
Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B[Fix]=20Update=20Web=20Utilities=20?=
=?UTF-8?q?links=20for=20v2.2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.github/workflows/deploy.yml | 1 +
.github/workflows/validate.yml | 1 +
README.md | 10 ++--
docs/deployment.md | 39 +++++---------
docs/migrations/h3-migration-contract.md | 4 ++
docs/migrations/h3-url-map.csv | 36 ++++++-------
docs/migrations/h3.5-cutover-runbook.md | 4 ++
docs/migrations/v2.2-tool-links.md | 68 ++++++++++++++++++++++++
docs/seo.md | 22 ++++----
public/_redirects | 32 +++++------
public/products/web-utilities/index.html | 27 ++++++++--
scripts/test_h3_url_map.py | 64 ++++++++++++++++++++++
scripts/validate-h3-url-map.py | 68 ++++++++++++++++++++++--
13 files changed, 289 insertions(+), 87 deletions(-)
create mode 100644 docs/migrations/v2.2-tool-links.md
create mode 100644 scripts/test_h3_url_map.py
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
index d87477a..319c763 100644
--- a/.github/workflows/deploy.yml
+++ b/.github/workflows/deploy.yml
@@ -66,6 +66,7 @@ jobs:
python scripts/validate-h3-url-map.py
python scripts/validate-h3-hub-cutover.py
+ python -m unittest discover -s scripts -p "test_*.py"
echo "Validated static deployment output: public/"
diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml
index c8baaad..d685ef2 100644
--- a/.github/workflows/validate.yml
+++ b/.github/workflows/validate.yml
@@ -25,3 +25,4 @@ jobs:
set -euo pipefail
python scripts/validate-h3-url-map.py
python scripts/validate-h3-hub-cutover.py
+ python -m unittest discover -s scripts -p "test_*.py"
diff --git a/README.md b/README.md
index ac1db18..1304f44 100644
--- a/README.md
+++ b/README.md
@@ -9,12 +9,10 @@ Secure Tools products. Products and libraries remain independently maintained an
## Status
-The repository now includes its information architecture, standardized product disclosure
-model, and a production-polished visual system aligned with Secure Tools Web Utilities, but it
-is not released as the production Hub.
-Production migration has not happened: `securetools.app` remains assigned to Secure Tools Web
-Utilities. The configured workflow publishes `main` only to the Cloudflare-managed `pages.dev`
-validation target.
+The Hub is live at `https://securetools.app/`. It discovers independently maintained
+products; Web Utilities is hosted at `https://tools.securetools.app/`.
+GitHub Actions validates and deploys the static `public/` directory to Cloudflare Pages.
+See [the v2.2 link migration](docs/migrations/v2.2-tool-links.md) for canonical tool destinations.
## Documentation
diff --git a/docs/deployment.md b/docs/deployment.md
index 935012d..28b6b1e 100644
--- a/docs/deployment.md
+++ b/docs/deployment.md
@@ -39,34 +39,19 @@ workflow's short-lived `GITHUB_TOKEN` so that each upload creates or updates a v
Deployment record. The workflow has only `contents: read` and `deployments: write`
permissions.
-## Current validation deployment
+## Production identity
-The current deployment target is the Cloudflare Pages-managed
-`https://secure-tools-hub-53i.pages.dev` site. This endpoint is for validating the Hub
-deployment path and does not mean that the Hub has become the Secure Tools production site.
+`https://securetools.app/` serves the Hub. `https://tools.securetools.app/` serves Web Utilities.
+The stable and immutable `secure-tools-hub-53i.pages.dev` aliases remain validation endpoints
+with hostname-specific noindex headers. The Hub is a static catalog, not a tool runtime.
-## Future production domain
+## Redirect contract
-`https://securetools.app` is **not yet connected to this repository**. It remains assigned to
-Secure Tools Web Utilities. This workflow does not change DNS, configure a custom domain, or
-perform the future production migration.
+`public/_redirects` preserves the 18 historical apex source paths and sends them directly
+to root-level canonical Web Utilities URLs with 301 responses. The root and all Hub routes
+remain Hub-owned. Query strings are preserved by Pages redirect behavior.
+The migration CSV documents historical sources, canonical targets, and tools-host 308 support.
+See [the v2.2 link migration](./migrations/v2.2-tool-links.md).
-Any production domain migration and related redirects must be handled as a separate,
-explicitly reviewed milestone.
-
-## Prepared H3.5 deployment contract
-
-The unmerged H3.4B branch prepares static `public/_headers` and `public/_redirects`
-artifacts. The hostname-specific header rules keep the stable and immutable
-`*.secure-tools-hub-53i.pages.dev` aliases non-indexable without applying noindex to the
-future custom domain. The redirects contain only the 18 explicit H3.1 legacy Web Utilities
-paths and preserve each path on `https://tools.securetools.app`; the Hub root and all Hub
-routes are excluded.
-
-Cloudflare Pages path redirects do not implement the future `www → apex` domain redirect.
-That change requires a Cloudflare zone/account-level Redirect Rule or Bulk Redirect plus
-proxied DNS during the coordinated H3.5 window. The exact activation and rollback order is
-documented in [the H3.5 cutover runbook](./migrations/h3.5-cutover-runbook.md).
-
-The H3.4B pull request does not attach a custom domain, change DNS, activate a `www` rule,
-modify Search Console, or deploy from its feature branch.
+This content/link migration changes no DNS, custom domains, TLS, zone rules, Search Console,
+or Web Utilities code. The H3.5 runbook is retained as a historical cutover record.
diff --git a/docs/migrations/h3-migration-contract.md b/docs/migrations/h3-migration-contract.md
index fd2c92d..009b0eb 100644
--- a/docs/migrations/h3-migration-contract.md
+++ b/docs/migrations/h3-migration-contract.md
@@ -1,5 +1,9 @@
# H3.1 — Domain Migration Contract and URL Inventory
+> Historical H3 preparation record. The apex now serves the Hub and Web Utilities uses
+> root-level canonical routes. The old same-path destination contract below is superseded
+> by [the verified v2.2 migration](./v2.2-tool-links.md); do not execute this historical runbook.
+
Status: planning only. Nothing in this document authorizes a DNS, hosting, custom-domain, redirect, metadata, or Search Console change.
Issue: [#12](https://github.com/SecureToolsProject/hub/issues/12)
diff --git a/docs/migrations/h3-url-map.csv b/docs/migrations/h3-url-map.csv
index 556debc..0d90a6f 100644
--- a/docs/migrations/h3-url-map.csv
+++ b/docs/migrations/h3-url-map.csv
@@ -1,20 +1,20 @@
old_url,new_url,status,reason
https://securetools.app/,https://securetools.app/,no_redirect,The apex root becomes the Hub and must not redirect
-https://securetools.app/about/,https://tools.securetools.app/about/,301,Preserve the existing Web Utilities path on the tools host
-https://securetools.app/privacy/,https://tools.securetools.app/privacy/,301,Preserve the existing Web Utilities path on the tools host
-https://securetools.app/tools/pdf/,https://tools.securetools.app/tools/pdf/,301,Preserve the existing Web Utilities path on the tools host
-https://securetools.app/tools/pdf/images-to-pdf/,https://tools.securetools.app/tools/pdf/images-to-pdf/,301,Preserve the existing Web Utilities path on the tools host
-https://securetools.app/tools/pdf/merge/,https://tools.securetools.app/tools/pdf/merge/,301,Preserve the existing Web Utilities path on the tools host
-https://securetools.app/tools/pdf/split/,https://tools.securetools.app/tools/pdf/split/,301,Preserve the existing Web Utilities path on the tools host
-https://securetools.app/tools/pdf/organize/,https://tools.securetools.app/tools/pdf/organize/,301,Preserve the existing Web Utilities path on the tools host
-https://securetools.app/tools/pdf/to-images/,https://tools.securetools.app/tools/pdf/to-images/,301,Preserve the existing Web Utilities path on the tools host
-https://securetools.app/tools/pdf/metadata/,https://tools.securetools.app/tools/pdf/metadata/,301,Preserve the existing Web Utilities path on the tools host
-https://securetools.app/tools/image/,https://tools.securetools.app/tools/image/,301,Preserve the existing Web Utilities path on the tools host
-https://securetools.app/tools/image/converter/,https://tools.securetools.app/tools/image/converter/,301,Preserve the existing Web Utilities path on the tools host
-https://securetools.app/tools/image/resize/,https://tools.securetools.app/tools/image/resize/,301,Preserve the existing Web Utilities path on the tools host
-https://securetools.app/tools/image/compress/,https://tools.securetools.app/tools/image/compress/,301,Preserve the existing Web Utilities path on the tools host
-https://securetools.app/tools/image/metadata/,https://tools.securetools.app/tools/image/metadata/,301,Preserve the existing Web Utilities path on the tools host
-https://securetools.app/tools/privacy/,https://tools.securetools.app/tools/privacy/,301,Preserve the existing Web Utilities path on the tools host
-https://securetools.app/tools/scan/,https://tools.securetools.app/tools/scan/,301,Preserve the existing Web Utilities path on the tools host
-https://securetools.app/tools/media/,https://tools.securetools.app/tools/media/,301,Preserve the existing Web Utilities path on the tools host
-https://securetools.app/tools/image-to-pdf/,https://tools.securetools.app/tools/image-to-pdf/,301,Preserve the existing noindex legacy interstitial without combining path cleanup
+https://securetools.app/about/,https://tools.securetools.app/about/,301,Historical apex URL; direct canonical tools-host target
+https://securetools.app/privacy/,https://tools.securetools.app/privacy/,301,Historical apex URL; direct canonical tools-host target
+https://securetools.app/tools/pdf/,https://tools.securetools.app/pdf/,301,Historical apex URL; direct v2.2 canonical target; tools-host legacy URL retains 308 support
+https://securetools.app/tools/pdf/images-to-pdf/,https://tools.securetools.app/pdf/images-to-pdf/,301,Historical apex URL; direct v2.2 canonical target; tools-host legacy URL retains 308 support
+https://securetools.app/tools/pdf/merge/,https://tools.securetools.app/pdf/merge/,301,Historical apex URL; direct v2.2 canonical target; tools-host legacy URL retains 308 support
+https://securetools.app/tools/pdf/split/,https://tools.securetools.app/pdf/split/,301,Historical apex URL; direct v2.2 canonical target; tools-host legacy URL retains 308 support
+https://securetools.app/tools/pdf/organize/,https://tools.securetools.app/pdf/organize/,301,Historical apex URL; direct v2.2 canonical target; tools-host legacy URL retains 308 support
+https://securetools.app/tools/pdf/to-images/,https://tools.securetools.app/pdf/to-images/,301,Historical apex URL; direct v2.2 canonical target; tools-host legacy URL retains 308 support
+https://securetools.app/tools/pdf/metadata/,https://tools.securetools.app/pdf/metadata/,301,Historical apex URL; direct v2.2 canonical target; tools-host legacy URL retains 308 support
+https://securetools.app/tools/image/,https://tools.securetools.app/image/,301,Historical apex URL; direct v2.2 canonical target; tools-host legacy URL retains 308 support
+https://securetools.app/tools/image/converter/,https://tools.securetools.app/image/converter/,301,Historical apex URL; direct v2.2 canonical target; tools-host legacy URL retains 308 support
+https://securetools.app/tools/image/resize/,https://tools.securetools.app/image/resize/,301,Historical apex URL; direct v2.2 canonical target; tools-host legacy URL retains 308 support
+https://securetools.app/tools/image/compress/,https://tools.securetools.app/image/compress/,301,Historical apex URL; direct v2.2 canonical target; tools-host legacy URL retains 308 support
+https://securetools.app/tools/image/metadata/,https://tools.securetools.app/image/metadata/,301,Historical apex URL; direct v2.2 canonical target; tools-host legacy URL retains 308 support
+https://securetools.app/tools/privacy/,https://tools.securetools.app/privacy/,301,Historical apex URL; direct v2.2 canonical target; tools-host legacy URL retains 308 support
+https://securetools.app/tools/scan/,https://tools.securetools.app/scan/,301,Historical apex URL; direct v2.2 canonical target; tools-host legacy URL retains 308 support; unavailable category remains unpublished
+https://securetools.app/tools/media/,https://tools.securetools.app/media/,301,Historical apex URL; direct v2.2 canonical target; tools-host legacy URL retains 308 support; unavailable category remains unpublished
+https://securetools.app/tools/image-to-pdf/,https://tools.securetools.app/pdf/images-to-pdf/,301,Historical apex URL; direct v2.2 canonical target; tools-host legacy URL retains 308 support
diff --git a/docs/migrations/h3.5-cutover-runbook.md b/docs/migrations/h3.5-cutover-runbook.md
index d538334..891ed99 100644
--- a/docs/migrations/h3.5-cutover-runbook.md
+++ b/docs/migrations/h3.5-cutover-runbook.md
@@ -1,5 +1,9 @@
# H3.5 coordinated cutover runbook
+> Historical H3 preparation record. The apex now serves the Hub and Web Utilities uses
+> root-level canonical routes. The old same-path destination contract below is superseded
+> by [the verified v2.2 migration](./v2.2-tool-links.md); do not execute this historical runbook.
+
Status: prepared by H3.4B; do not execute from the preparation pull request.
This runbook coordinates the final architecture:
diff --git a/docs/migrations/v2.2-tool-links.md b/docs/migrations/v2.2-tool-links.md
new file mode 100644
index 0000000..5db5689
--- /dev/null
+++ b/docs/migrations/v2.2-tool-links.md
@@ -0,0 +1,68 @@
+# Verified v2.2 Hub tool URL migration
+
+Base: SecureToolsProject/hub main c99f52fcadfbb4c701238b8030d924c9e4496698.
+Web Utilities production main: 4b07f2962e524f4cfa5736de35e0f31ad52aaa15.
+The live tools sitemap and route manifest are the canonical reference; all 19 destinations
+returned HTTP 200 with zero redirect hops before editing.
+
+## Audit before editing
+
+- public/_redirects: 16 legacy tools-host destinations among 18 exact redirects.
+- docs/migrations/h3-url-map.csv: the same 16 stale destination URLs; preserve historical sources.
+- scripts/validate-h3-url-map.py: enforced obsolete same-path destinations.
+- docs/deployment.md and docs/seo.md: repeated the obsolete/currently inaccurate contract.
+- docs/migrations/h3-migration-contract.md and h3.5-cutover-runbook.md: historical same-path
+ instructions, now clearly marked superseded; preserve historical route tables.
+- public/products/web-utilities/index.html: two canonical root entry links, no individual
+ tool discovery; old cutover wording. Add available tool links using its existing list design.
+- README.md: stale pre-production status.
+- Other source, public assets, navigation, metadata, sitemap and robots: no stale published
+ tools-host destinations. Hub has English-only static content, no locale/theme controls.
+
+## Exact apex-source to tools-host canonical mapping
+
+| Historical apex source | Canonical tools-host destination |
+| --- | --- |
+| /about/ | /about/ |
+| /privacy/ | /privacy/ |
+| /tools/pdf/ | /pdf/ |
+| /tools/pdf/images-to-pdf/ | /pdf/images-to-pdf/ |
+| /tools/pdf/merge/ | /pdf/merge/ |
+| /tools/pdf/split/ | /pdf/split/ |
+| /tools/pdf/organize/ | /pdf/organize/ |
+| /tools/pdf/to-images/ | /pdf/to-images/ |
+| /tools/pdf/metadata/ | /pdf/metadata/ |
+| /tools/image/ | /image/ |
+| /tools/image/converter/ | /image/converter/ |
+| /tools/image/resize/ | /image/resize/ |
+| /tools/image/compress/ | /image/compress/ |
+| /tools/image/metadata/ | /image/metadata/ |
+| /tools/privacy/ | /privacy/ |
+| /tools/scan/ | /scan/ |
+| /tools/media/ | /media/ |
+| /tools/image-to-pdf/ | /pdf/images-to-pdf/ |
+
+The root remains the Hub with no redirect. Tools-host `/tools/*` URLs remain supported
+historically through 308 redirects, but are never Hub destinations. The image-to-PDF alias
+maps directly to `/pdf/images-to-pdf/`. PDF to Text is new since the original H3 inventory:
+link directly to `/pdf/to-text/`, with Searchable PDF integrated there; do not invent a legacy
+redirect or a separate Searchable PDF route. Scan/media legacy redirects preserve historical
+routing only; those unavailable tools remain absent from discovery. No new tool is activated.
+
+## Validation
+
+The Hub has no package manager, install dependencies, compilation, or separate build step.
+`public/` is the unchanged static deployment output format. Run:
+
+```text
+python scripts/validate-h3-url-map.py
+python scripts/validate-h3-hub-cutover.py
+python -m unittest discover -s scripts -p "test_*.py"
+git diff --check
+```
+
+The existing URL validator now checks canonical destinations, exact historical sources,
+discovery links, unpublished tools and redirect-map consistency. SEO validation retains
+10 Hub-only canonical pages, sitemap/robots and Pages-alias isolation. Regression tests
+exercise stale destinations, aliases, missing PDF OCR discovery and unavailable tool links.
+DNS, Search Console, Web Utilities code, tags and releases are outside this change.
diff --git a/docs/seo.md b/docs/seo.md
index 810d28e..eabf7e7 100644
--- a/docs/seo.md
+++ b/docs/seo.md
@@ -1,7 +1,7 @@
# Hub search metadata
-Status: H3.4B preparation only. The pull request must remain unmerged until the coordinated
-H3.5 cutover.
+Status: production Hub. The v2.2 link migration updates tool destinations without changing
+Hub canonical metadata, sitemap, robots, or indexing policy.
## Final canonical identity
@@ -29,27 +29,25 @@ https://secure-tools-hub-53i.pages.dev/*
https://:version.secure-tools-hub-53i.pages.dev/*
```
-The future `securetools.app` custom domain does not match those patterns and remains
+The production `securetools.app` custom domain does not match those patterns and remains
indexable. No Worker or Pages Function is required.
## Legacy path ownership
`public/_redirects` contains exactly the 18 explicit 301 mappings in
-`docs/migrations/h3-url-map.csv`. Every destination is the same path on
-`https://tools.securetools.app`. The Hub root and all Hub routes are excluded; no wildcard
+`docs/migrations/h3-url-map.csv`. Every destination is the root-level canonical path on
+`https://tools.securetools.app`, including the historical image-to-PDF alias. The Hub root and all Hub routes are excluded; no wildcard
can swallow future Hub content.
-These redirects become reachable on the apex only after H3.5 attaches the custom domain to
-the Hub Pages project. The H3.4B feature branch does not deploy or activate them.
+The apex redirects go directly to canonical tools URLs. Historical `/tools/*` sources are
+retained; destination URLs no longer rely on the tools host's legacy 308 redirects.
## Validation and search activation
`scripts/validate-h3-hub-cutover.py` checks route metadata, social image dimensions,
sitemap, robots, and Pages-alias isolation. `scripts/validate-h3-url-map.py` compares the
redirect artifact directly with the H3.1 inventory and rejects duplicates, wildcards, wrong
-hosts, changed paths, non-301 status, root redirects, and Hub-route collisions.
+hosts, incorrect canonical targets, non-301 status, root redirects, and Hub-route collisions.
-Search Console remains unchanged during preparation. After H3.5 HTTP, TLS, canonical, and
-redirect validation, submit the Hub sitemap to the root property and monitor Web Utilities
-through the tools URL-prefix property. Do not use Change of Address for this partial
-migration.
+Search Console and DNS remain unchanged by the v2.2 link migration. Historical activation
+instructions remain in the archived H3.5 runbook.
diff --git a/public/_redirects b/public/_redirects
index f7d2f37..22a58ad 100644
--- a/public/_redirects
+++ b/public/_redirects
@@ -1,18 +1,18 @@
/about/ https://tools.securetools.app/about/ 301
/privacy/ https://tools.securetools.app/privacy/ 301
-/tools/pdf/ https://tools.securetools.app/tools/pdf/ 301
-/tools/pdf/images-to-pdf/ https://tools.securetools.app/tools/pdf/images-to-pdf/ 301
-/tools/pdf/merge/ https://tools.securetools.app/tools/pdf/merge/ 301
-/tools/pdf/split/ https://tools.securetools.app/tools/pdf/split/ 301
-/tools/pdf/organize/ https://tools.securetools.app/tools/pdf/organize/ 301
-/tools/pdf/to-images/ https://tools.securetools.app/tools/pdf/to-images/ 301
-/tools/pdf/metadata/ https://tools.securetools.app/tools/pdf/metadata/ 301
-/tools/image/ https://tools.securetools.app/tools/image/ 301
-/tools/image/converter/ https://tools.securetools.app/tools/image/converter/ 301
-/tools/image/resize/ https://tools.securetools.app/tools/image/resize/ 301
-/tools/image/compress/ https://tools.securetools.app/tools/image/compress/ 301
-/tools/image/metadata/ https://tools.securetools.app/tools/image/metadata/ 301
-/tools/privacy/ https://tools.securetools.app/tools/privacy/ 301
-/tools/scan/ https://tools.securetools.app/tools/scan/ 301
-/tools/media/ https://tools.securetools.app/tools/media/ 301
-/tools/image-to-pdf/ https://tools.securetools.app/tools/image-to-pdf/ 301
+/tools/pdf/ https://tools.securetools.app/pdf/ 301
+/tools/pdf/images-to-pdf/ https://tools.securetools.app/pdf/images-to-pdf/ 301
+/tools/pdf/merge/ https://tools.securetools.app/pdf/merge/ 301
+/tools/pdf/split/ https://tools.securetools.app/pdf/split/ 301
+/tools/pdf/organize/ https://tools.securetools.app/pdf/organize/ 301
+/tools/pdf/to-images/ https://tools.securetools.app/pdf/to-images/ 301
+/tools/pdf/metadata/ https://tools.securetools.app/pdf/metadata/ 301
+/tools/image/ https://tools.securetools.app/image/ 301
+/tools/image/converter/ https://tools.securetools.app/image/converter/ 301
+/tools/image/resize/ https://tools.securetools.app/image/resize/ 301
+/tools/image/compress/ https://tools.securetools.app/image/compress/ 301
+/tools/image/metadata/ https://tools.securetools.app/image/metadata/ 301
+/tools/privacy/ https://tools.securetools.app/privacy/ 301
+/tools/scan/ https://tools.securetools.app/scan/ 301
+/tools/media/ https://tools.securetools.app/media/ 301
+/tools/image-to-pdf/ https://tools.securetools.app/pdf/images-to-pdf/ 301
diff --git a/public/products/web-utilities/index.html b/public/products/web-utilities/index.html
index 440f643..792c60d 100644
--- a/public/products/web-utilities/index.html
+++ b/public/products/web-utilities/index.html
@@ -62,7 +62,7 @@ Secure Tools Web Utilities
Secure Tools ecosystem.
@@ -138,11 +138,30 @@ Website delivery and file processing are different
Entry point and migration boundary
- Web application: tools.securetools.app
- hosts the parallel Web Utilities deployment and becomes the product's canonical
- public endpoint during the coordinated H3.5 cutover.
+ Web application: tools.securetools.app
+ is the canonical production endpoint. Tools use root-level paths; legacy
+ /tools/ URLs remain supported through redirects.
+
+
+
+ Searchable PDF is part of PDF to Text. Document Scanner remains unavailable.
+
Source and technical documentation
diff --git a/scripts/test_h3_url_map.py b/scripts/test_h3_url_map.py
new file mode 100644
index 0000000..cfdeb39
--- /dev/null
+++ b/scripts/test_h3_url_map.py
@@ -0,0 +1,64 @@
+"""Regression coverage for canonical Hub destinations and release availability."""
+import contextlib
+import importlib.util
+import io
+import shutil
+import tempfile
+import unittest
+from pathlib import Path
+
+ROOT = Path(__file__).resolve().parents[1]
+spec = importlib.util.spec_from_file_location("url_map", ROOT / "scripts/validate-h3-url-map.py")
+validator = importlib.util.module_from_spec(spec)
+spec.loader.exec_module(validator)
+
+class MigrationTests(unittest.TestCase):
+ def setUp(self):
+ self.temp = tempfile.TemporaryDirectory()
+ self.root = Path(self.temp.name)
+ shutil.copytree(ROOT / "public", self.root / "public")
+ shutil.copytree(ROOT / "docs/migrations", self.root / "docs/migrations")
+ self.original = validator.MAP_PATH, validator.PUBLIC_ROOT, validator.REDIRECTS_PATH
+ validator.MAP_PATH = self.root / "docs/migrations/h3-url-map.csv"
+ validator.PUBLIC_ROOT = self.root / "public"
+ validator.REDIRECTS_PATH = validator.PUBLIC_ROOT / "_redirects"
+ def tearDown(self):
+ validator.MAP_PATH, validator.PUBLIC_ROOT, validator.REDIRECTS_PATH = self.original
+ self.temp.cleanup()
+ def result(self):
+ with contextlib.redirect_stdout(io.StringIO()), contextlib.redirect_stderr(io.StringIO()):
+ return validator.main()
+ def change(self, path, old, new):
+ p = self.root / path
+ text = p.read_text(encoding="utf-8")
+ self.assertIn(old, text)
+ p.write_text(text.replace(old, new), encoding="utf-8")
+ def test_current_contract_passes(self):
+ self.assertEqual(self.result(), 0)
+ def test_stale_csv_target_rejected(self):
+ self.change("docs/migrations/h3-url-map.csv", "https://tools.securetools.app/pdf/merge/", "https://tools.securetools.app/tools/pdf/merge/")
+ self.assertEqual(self.result(), 1)
+ def test_stale_redirect_target_rejected(self):
+ self.change("public/_redirects", "https://tools.securetools.app/pdf/split/", "https://tools.securetools.app/tools/pdf/split/")
+ self.assertEqual(self.result(), 1)
+ def test_legacy_published_link_rejected(self):
+ self.change("public/products/web-utilities/index.html", "https://tools.securetools.app/image/resize/", "https://tools.securetools.app/tools/image/resize/")
+ self.assertEqual(self.result(), 1)
+ def test_pdf_ocr_discovery_required(self):
+ self.change("public/products/web-utilities/index.html", "https://tools.securetools.app/pdf/to-text/", "https://tools.securetools.app/pdf/")
+ self.assertEqual(self.result(), 1)
+ def test_document_scanner_not_published(self):
+ self.change("public/products/web-utilities/index.html", "https://tools.securetools.app/image/to-text/", "https://tools.securetools.app/scan/")
+ self.assertEqual(self.result(), 1)
+ def test_apex_redirect_loop_rejected(self):
+ self.change("public/_redirects", "https://tools.securetools.app/pdf/merge/", "https://securetools.app/tools/pdf/merge/")
+ self.assertEqual(self.result(), 1)
+ def test_image_to_pdf_alias_must_target_final_tool(self):
+ self.change("public/_redirects", "/tools/image-to-pdf/ https://tools.securetools.app/pdf/images-to-pdf/", "/tools/image-to-pdf/ https://tools.securetools.app/image-to-pdf/")
+ self.assertEqual(self.result(), 1)
+ def test_extra_speculative_legacy_route_rejected(self):
+ self.change("docs/migrations/h3-url-map.csv", "/tools/pdf/merge/", "/tools/pdf/to-text/")
+ self.assertEqual(self.result(), 1)
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/scripts/validate-h3-url-map.py b/scripts/validate-h3-url-map.py
index 324bddd..66ef3d2 100644
--- a/scripts/validate-h3-url-map.py
+++ b/scripts/validate-h3-url-map.py
@@ -6,6 +6,7 @@
import csv
import sys
from pathlib import Path
+from html.parser import HTMLParser
from urllib.parse import urlsplit
@@ -16,6 +17,45 @@
EXPECTED_FIELDS = ["old_url", "new_url", "status", "reason"]
+
+# Verified Web Utilities production sitemap: no legacy destination may be published.
+CANONICAL_ROUTES = {
+ "/", "/about/", "/privacy/", "/pdf/", "/pdf/images-to-pdf/",
+ "/pdf/merge/", "/pdf/split/", "/pdf/organize/", "/pdf/to-images/",
+ "/pdf/metadata/", "/pdf/to-text/", "/image/", "/image/converter/",
+ "/image/resize/", "/image/compress/", "/image/metadata/", "/image/to-text/",
+ "/scan/", "/media/",
+}
+UNPUBLISHED_ROUTES = {"/scan/", "/media/"}
+DISCOVERY_ROUTES = {
+ "/image/to-text/", "/image/resize/", "/image/converter/", "/image/compress/",
+ "/image/metadata/", "/pdf/images-to-pdf/", "/pdf/merge/", "/pdf/split/",
+ "/pdf/organize/", "/pdf/to-images/", "/pdf/metadata/", "/pdf/to-text/", "/privacy/",
+}
+LEGACY_ROUTES = {
+ "/about/", "/privacy/", "/tools/pdf/", "/tools/pdf/images-to-pdf/",
+ "/tools/pdf/merge/", "/tools/pdf/split/", "/tools/pdf/organize/",
+ "/tools/pdf/to-images/", "/tools/pdf/metadata/", "/tools/image/",
+ "/tools/image/converter/", "/tools/image/resize/", "/tools/image/compress/",
+ "/tools/image/metadata/", "/tools/privacy/", "/tools/scan/", "/tools/media/",
+ "/tools/image-to-pdf/",
+}
+
+def canonical_path(path: str) -> str:
+ if path == "/tools/image-to-pdf/":
+ return "/pdf/images-to-pdf/"
+ return path.removeprefix("/tools") if path.startswith("/tools/") else path
+
+class PublishedURLs(HTMLParser):
+ def __init__(self):
+ super().__init__()
+ self.urls = []
+ def handle_starttag(self, tag, attrs):
+ for name, value in attrs:
+ if value and name in {"href", "src", "content"}:
+ self.urls.append(value)
+
+
def hub_routes() -> set[str]:
routes: set[str] = set()
for index_file in PUBLIC_ROOT.rglob("index.html"):
@@ -71,8 +111,8 @@ def main() -> int:
redirect_count += 1
if new.scheme != "https" or new.netloc != "tools.securetools.app":
errors.append(f"line {line_number}: redirect target must use https://tools.securetools.app")
- if old.path != new.path:
- errors.append(f"line {line_number}: redirect target does not preserve {old.path}")
+ if new.path != canonical_path(old.path) or new.path not in CANONICAL_ROUTES:
+ errors.append(f"line {line_number}: incorrect canonical target for {old.path}")
if old.path in current_hub_routes:
errors.append(f"line {line_number}: legacy redirect collides with Hub route {old.path}")
expected_redirects[old.path] = new_url
@@ -110,8 +150,8 @@ def main() -> int:
errors.append(f"_redirects line {line_number}: status must be 301")
if target.scheme != "https" or target.netloc != "tools.securetools.app":
errors.append(f"_redirects line {line_number}: target host must be tools.securetools.app")
- if source != target.path:
- errors.append(f"_redirects line {line_number}: target must preserve path {source}")
+ if target.path != canonical_path(source) or target.path not in CANONICAL_ROUTES:
+ errors.append(f"_redirects line {line_number}: incorrect canonical target for {source}")
actual_redirects[source] = destination
if actual_redirects != expected_redirects:
@@ -127,6 +167,26 @@ def main() -> int:
f"(missing={missing}, unexpected={unexpected}, mismatched={mismatched})"
)
+ if set(expected_redirects) != LEGACY_ROUTES:
+ errors.append("legacy source inventory changed")
+ discovered = set()
+ for page in PUBLIC_ROOT.rglob("*.html"):
+ parser = PublishedURLs()
+ parser.feed(page.read_text(encoding="utf-8"))
+ for value in parser.urls:
+ url = urlsplit(value)
+ if url.netloc == "tools.securetools.app":
+ route = url.path or "/"
+ if url.scheme != "https" or route not in CANONICAL_ROUTES:
+ errors.append(f"{page.name}: non-canonical published tool URL {value}")
+ if route in UNPUBLISHED_ROUTES:
+ errors.append(f"{page.name}: unavailable tool published {value}")
+ discovered.add(route)
+ elif not url.netloc and url.path.startswith("/tools/"):
+ errors.append(f"{page.name}: legacy tool href {value}")
+ if not DISCOVERY_ROUTES <= discovered:
+ errors.append(f"missing tool discovery: {sorted(DISCOVERY_ROUTES - discovered)}")
+
if errors:
for error in errors:
print(f"ERROR: {error}", file=sys.stderr)