@@ -136,7 +136,7 @@ $Queue | ForEach-Object {
136136 $regex = ' '
137137 }
138138
139- $jsonpath = ' '
139+ $jsonpath = @ {}
140140 $xpath = ' '
141141 $replace = ' '
142142 $useGithubAPI = $false
@@ -196,12 +196,16 @@ $Queue | ForEach-Object {
196196 $regex = " CDATA\[/$path /.*?$sourceforgeRegex .*?\]" .Replace(' //' , ' /' )
197197 }
198198
199+ $jp_ = ' '
200+
199201 if ($json.checkver.jp ) {
200- $jsonpath = $json.checkver.jp
202+ $jp_ = $json.checkver.jp
201203 }
204+
202205 if ($json.checkver.jsonpath ) {
203- $jsonpath = $json.checkver.jsonpath
206+ $jp_ = $json.checkver.jsonpath
204207 }
208+
205209 if ($json.checkver.xpath ) {
206210 $xpath = $json.checkver.xpath
207211 }
@@ -212,13 +216,15 @@ $Queue | ForEach-Object {
212216 }
213217
214218 # If the jsonpath is a string that's not empty, make it a hashtable with a `version` field.
215- if ($jsonpath.GetType () -eq [System.String ] -and ! [String ]::IsNullOrEmpty($jsonpath )) {
216- $jsonpath = @ {
217- version = $jsonpath
219+ if (($jp_.GetType () -eq [System.String ]) -and ! [String ]::IsNullOrEmpty($jp_ )) {
220+ $jsonpath.Add (' version' , $jp_ )
221+ } elseif (! [String ]::IsNullOrEmpty($jp_ )) {
222+ $json.checkver.jsonpath.psobject.properties | ForEach-Object {
223+ $jsonpath.Add ($_.Name , $_.Value )
218224 }
219225 }
220226
221- if (! $jsonpath -and ! $regex -and ! $xpath ) {
227+ if (! $jsonpath.Count -and ! $regex -and ! $xpath ) {
222228 $regex = $json.checkver
223229 }
224230
@@ -281,7 +287,6 @@ while ($in_progress -gt 0) {
281287 $replace = $state.replace
282288 $expected_ver = $json.version
283289 $ver = $Version
284- $source = $url
285290 $matchesHashtable = @ {}
286291
287292 if (! $ver ) {
@@ -295,10 +300,7 @@ while ($in_progress -gt 0) {
295300 continue
296301 }
297302
298- if ($script ) {
299- $page = Invoke-Command ([scriptblock ]::Create($script -join " `r`n " ))
300- $source = ' the output of script'
301- } elseif ($url ) {
303+ if ($url ) {
302304 $ms = New-Object System.IO.MemoryStream
303305 $ms.Write ($result , 0 , $result.Length )
304306 $ms.Seek (0 , 0 ) | Out-Null
@@ -307,8 +309,13 @@ while ($in_progress -gt 0) {
307309 }
308310 $page = (New-Object System.IO.StreamReader($ms , (Get-Encoding $wc ))).ReadToEnd()
309311 }
312+ $source = $url
313+ if ($script ) {
314+ $page = Invoke-Command ([scriptblock ]::Create($script -join " `r`n " ))
315+ $source = ' the output of script'
316+ }
310317
311- if ($jsonpath ) {
318+ if ($jsonpath.Count ) {
312319 # Return only a single value if regex is absent
313320 # $noregex = [String]::IsNullOrEmpty($regexp)
314321 # If reverse is ON and regex is ON,
@@ -361,7 +368,7 @@ while ($in_progress -gt 0) {
361368 }
362369 }
363370
364- if ($jsonpath -and $regexp ) {
371+ if ($jsonpath.Count -and $regexp ) {
365372 $page = $ver
366373 $ver = ' '
367374 }
0 commit comments