32 lines
1.6 KiB
PowerShell
32 lines
1.6 KiB
PowerShell
# W3: fix dead domain + non-www JSON-LD URLs across all index.html files (case-insensitive)
|
|
$repo = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
|
|
$excludePattern = '\\(\.git|node_modules|seo-audit-2026-05-27|website|directory)\\'
|
|
$files = Get-ChildItem $repo -Recurse -Filter index.html -File -ErrorAction SilentlyContinue |
|
|
Where-Object { $_.FullName -notmatch $excludePattern }
|
|
$tpl = Join-Path $repo 'templates\pillar-page.html'
|
|
if (Test-Path $tpl) { $files += (Get-Item $tpl) }
|
|
$eeat = Join-Path $repo 'components\eeat.js'
|
|
if (Test-Path $eeat) { $files += (Get-Item $eeat) }
|
|
|
|
$opts = [System.Text.RegularExpressions.RegexOptions]::IgnoreCase
|
|
$changed = 0
|
|
foreach ($file in $files) {
|
|
$c = [System.IO.File]::ReadAllText($file.FullName)
|
|
if (-not $c) { continue }
|
|
$orig = $c
|
|
# Normalize ALL occurrences of any case-variant of odoo-expertos.com to www.odoo-expertos.com
|
|
# Step 1: dead domain (no hyphen) -> www.odoo-expertos.com
|
|
$c = [regex]::Replace($c, 'https?://(?:www\.)?odooexpertos\.com', 'https://www.odoo-expertos.com', $opts)
|
|
# Step 2: protocol+(www.)?odoo-expertos.com -> https://www.odoo-expertos.com
|
|
$c = [regex]::Replace($c, 'https?://(?:www\.)?odoo-expertos\.com', 'https://www.odoo-expertos.com', $opts)
|
|
# Bare hostname (no protocol)
|
|
$c = [regex]::Replace($c, '(?<![./@\w-])(?:www\.)?odooexpertos\.com', 'www.odoo-expertos.com', $opts)
|
|
# Cleanup any accidental www.www.
|
|
$c = $c -replace 'www\.www\.odoo-expertos\.com', 'www.odoo-expertos.com'
|
|
if ($c -ne $orig) {
|
|
[System.IO.File]::WriteAllText($file.FullName, $c)
|
|
$changed++
|
|
}
|
|
}
|
|
Write-Host "W3 codemod: changed $changed of $($files.Count) files"
|