Prerequisites
Steps to reproduce
Using Invoke-RestMethod with -FollowRelLink works when the server returns a Link header with relation type rel="next", but not when the relation type is rel=next without quotes, although the Web Linking RFC allows it. Quotes are only required under specific circumstances, never for IANA relation types.
relation-types = relation-type
| <"> relation-type *( 1*SP relation-type ) <">
relation-type = reg-rel-type | ext-rel-type
reg-rel-type = LOALPHA *( LOALPHA | DIGIT | "." | "-" )
ext-rel-type = URI
Note that extension relation types are REQUIRED to be absolute URIs in Link headers, and MUST be quoted if they contain a semicolon (";") or comma (",") (as these characters are used as delimiters in the header itself).
The Regex pattern can be found here.
|
const string pattern = "<(?<url>.*?)>;\\s*rel=(\"?)(?<rel>.*?)\\1[^\\w -.]?"; |
Expected behavior
PS> Invoke-RestMethod "https://api.guildwars2.com/v2/quaggans?page=0&page_size=10" -FollowRelLink
id url
-- ---
404 https://static.staticwars.com/quaggans/404.jpg
aloha https://static.staticwars.com/quaggans/aloha.jpg
attack https://static.staticwars.com/quaggans/attack.jpg
bear https://static.staticwars.com/quaggans/bear.jpg
bowl https://static.staticwars.com/quaggans/bowl.jpg
box https://static.staticwars.com/quaggans/box.jpg
breakfast https://static.staticwars.com/quaggans/breakfast.jpg
bubble https://static.staticwars.com/quaggans/bubble.jpg
cake https://static.staticwars.com/quaggans/cake.jpg
cheer https://static.staticwars.com/quaggans/cheer.jpg
coffee https://static.staticwars.com/quaggans/coffee.jpg
construction https://static.staticwars.com/quaggans/construction.jpg
cow https://static.staticwars.com/quaggans/cow.jpg
cry https://static.staticwars.com/quaggans/cry.jpg
elf https://static.staticwars.com/quaggans/elf.jpg
ghost https://static.staticwars.com/quaggans/ghost.jpg
girl https://static.staticwars.com/quaggans/girl.jpg
hat https://static.staticwars.com/quaggans/hat.jpg
helmut https://static.staticwars.com/quaggans/helmut.jpg
hoodie-down https://static.staticwars.com/quaggans/hoodie-down.jpg
hoodie-up https://static.staticwars.com/quaggans/hoodie-up.jpg
killerwhale https://static.staticwars.com/quaggans/killerwhale.jpg
knight https://static.staticwars.com/quaggans/knight.jpg
lollipop https://static.staticwars.com/quaggans/lollipop.jpg
lost https://static.staticwars.com/quaggans/lost.jpg
moving https://static.staticwars.com/quaggans/moving.jpg
party https://static.staticwars.com/quaggans/party.jpg
present https://static.staticwars.com/quaggans/present.jpg
quaggan https://static.staticwars.com/quaggans/quaggan.jpg
rain https://static.staticwars.com/quaggans/rain.jpg
scifi https://static.staticwars.com/quaggans/scifi.jpg
seahawks https://static.staticwars.com/quaggans/seahawks.jpg
sleep https://static.staticwars.com/quaggans/sleep.jpg
summer https://static.staticwars.com/quaggans/summer.jpg
vacation https://static.staticwars.com/quaggans/vacation.jpg
Actual behavior
PS> Invoke-RestMethod "https://api.guildwars2.com/v2/quaggans?page=0&page_size=10" -FollowRelLink
id url
-- ---
404 https://static.staticwars.com/quaggans/404.jpg
aloha https://static.staticwars.com/quaggans/aloha.jpg
attack https://static.staticwars.com/quaggans/attack.jpg
bear https://static.staticwars.com/quaggans/bear.jpg
bowl https://static.staticwars.com/quaggans/bowl.jpg
box https://static.staticwars.com/quaggans/box.jpg
breakfast https://static.staticwars.com/quaggans/breakfast.jpg
bubble https://static.staticwars.com/quaggans/bubble.jpg
cake https://static.staticwars.com/quaggans/cake.jpg
cheer https://static.staticwars.com/quaggans/cheer.jpg
Error details
No response
Environment data
Name Value
---- -----
PSVersion 7.1.4
PSEdition Core
GitCommitId 7.1.4
OS Microsoft Windows 10.0.19043
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visuals

Prerequisites
Steps to reproduce
Using Invoke-RestMethod with
-FollowRelLinkworks when the server returns a Link header with relation typerel="next", but not when the relation type isrel=nextwithout quotes, although the Web Linking RFC allows it. Quotes are only required under specific circumstances, never for IANA relation types.The Regex pattern can be found here.
PowerShell/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs
Line 1833 in e70ad6c
Expected behavior
Actual behavior
Error details
No response
Environment data
Visuals