From 9fda5428ae6d10581283a8485b8b34f4a7f7ceb9 Mon Sep 17 00:00:00 2001 From: Hsiao-nan Cheung Date: Sat, 15 Oct 2022 20:17:48 +0800 Subject: [PATCH] builds(checkver): Support XML default namespace (#5191) --- CHANGELOG.md | 1 + bin/checkver.ps1 | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 580585eb8b..16bfe3bf1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ ### Builds - **auto-pr:** Add `CommitMessageFormat` option ([#5171](https://github.com/ScoopInstaller/Scoop/issues/5171)) +- **checkver:** Support XML default namespace ([#5191](https://github.com/ScoopInstaller/Scoop/issues/5191)) ## [v0.3.0](https://github.com/ScoopInstaller/Scoop/compare/v0.2.4...v0.3.0) - 2022-10-10 diff --git a/bin/checkver.ps1 b/bin/checkver.ps1 index 0205a36639..aeaf1914ce 100644 --- a/bin/checkver.ps1 +++ b/bin/checkver.ps1 @@ -310,12 +310,17 @@ while ($in_progress -gt 0) { # Then add them into the NamespaceManager $nsmgr = New-Object System.Xml.XmlNamespaceManager($xml.NameTable) $nsList | ForEach-Object { - $nsmgr.AddNamespace($_.LocalName, $_.Value) + if ($_.LocalName -eq 'xmlns') { + $nsmgr.AddNamespace('ns', $_.Value) + $xpath = $xpath -replace '/([^:/]+)((?=/)|(?=$))', '/ns:$1' + } else { + $nsmgr.AddNamespace($_.LocalName, $_.Value) + } } # Getting version from XML, using XPath $ver = $xml.SelectSingleNode($xpath, $nsmgr).'#text' if (!$ver) { - next "couldn't find '$xpath' in $url" + next "couldn't find '$($xpath -replace 'ns:', '')' in $url" continue } }