From 216202268e4470d268bbcdd55babfba3bce75cec Mon Sep 17 00:00:00 2001 From: StartAutomating Date: Sun, 19 Apr 2026 14:29:00 -0700 Subject: [PATCH 1/3] feat: `Get-JSONLD` improvement ( Fixes #12, Fixes #27 ) Aliasing to uri, handling direct JSON-LD links --- Commands/Get-JsonLD.ps1 | 175 +++++++++++++++++++++++++--------------- 1 file changed, 110 insertions(+), 65 deletions(-) diff --git a/Commands/Get-JsonLD.ps1 b/Commands/Get-JsonLD.ps1 index a7a5b71..23b34c5 100644 --- a/Commands/Get-JsonLD.ps1 +++ b/Commands/Get-JsonLD.ps1 @@ -21,7 +21,7 @@ function Get-JsonLD { param( # The URL that may contain JSON-LD data [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] - [Alias('href')] + [Alias('href','uri')] [Uri] $Url, @@ -42,10 +42,8 @@ function Get-JsonLD { [string] $as = 'jsonld', - [switch] - $RawHtml, - # If set, will force the request to be made even if the URL has already been cached. + [Alias('IgnoreCache')] [switch] $Force ) @@ -71,53 +69,140 @@ application/ld\+json # The type that indicates linked d $script:Cache = [Ordered]@{} } + # Construct a filter to match and output + filter matchAndOutput { + + $contentToMatch = $_ + if ($contentToMatch -match '^\s{0,}\{') { + $contentToMatch = "" + } + + if ($as -eq 'html') { + return $contentToMatch + } + + # Find all linked data tags within the response + foreach ($match in $linkedDataRegex.Matches("$($contentToMatch)")) { + # If we want the result as xml + if ($As -eq 'xml') { + # try to cast it + $matchXml ="$match" -as [xml] + if ($matchXml) { + # and output it if found. + $matchXml + continue + } else { + # otherwise, fall back to the `