Repository navigation
fix: return nil for a remote url that cannot be fetched - #390
Merged
Merged
Conversation
GetResource passed a remote url to resources.GetMatch when both download attempts failed. GetMatch treats the url as an asset pattern: a "[" in it fails the build with a glob syntax error, and on Windows the ":" in the url fails the build as an invalid path. The asset fallback now runs only for urls that are not remote. The getresource test group covers page resources, assets and two unfetchable remote urls. The live-editing renderer skips the group, since its harness replaces GetResource with a stub. Refs gethinode/hinode#2338 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
GetResource skipped the asset fallback for every url that starts with "http", so an asset name such as "http-logo.jpg" returned nil instead of the site asset. The fallback is now skipped only for a url that opens with the scheme "https://" or "https://", in any letter case. Other urls reach resources.GetMatch as they did before 980bc43. The getresource group adds three asset names that start with "http", in lower and upper case, an unreachable "https://" url, a protocol-relative url and a glob pattern that contains a url. Refs gethinode/hinode#2338 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The getresource runner now wraps GetResource in try and records a failed call as "error", so a case whose url reaches resources.GetMatch with an invalid pattern does not stop the build. The new case "http:/127.0.0.1:1/img/[x.png" has one slash after the scheme, so the asset fallback still runs and its "[" fails in GetMatch, as it does on main. With the partial from main, each unreachable remote case now fails as its own "error" line in the golden diff. Refs gethinode/hinode#2338 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
markdumay
enabled auto-merge
November 6, 2026 12:59
Collaborator
Author
|
🎉 This PR is included in version 6.18.2 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes gethinode/hinode#2338
Summary
When a remote URL can't be fetched,
utilities/GetResource.htmlnow returnsnil. It no longer passes that URL on toresources.GetMatchas a local asset pattern.Before this change, any URL that started with
httpand failed to download went through the asset fallback.:in the scheme becomes part of a file path, and the build fails. This surfaced in fix(seo): prefer page bundle images and emit og:image dimensions hinode#2337's Windows CI:CreateFile ...\assets\https:\127.0.0.1\img: The filename, directory name, or volume label syntax is incorrect.[in such a URL fails with a glob syntax error.The fallback is now skipped only for a URL that starts with
http://orhttps://, in any letter case.http-logo.jpgorHTTP-x.jpg, still resolve.//…, single-slashhttp:/…and other schemes behave exactly as before.Tests
A new
getresourcegolden group adds 13 cases:The remote URLs are denied by Hugo's default security policy, so no case touches the network. The test runner wraps this group's calls in
try, so each case that errors is recorded as"error".The new cases fail on
main: the three unreachable-remote cases give"error".pnpm testpasses with the fix. No existing golden file changes.An independent review compared
mainand this branch on 75 URL forms, with Hugo's default security policy and with a permissive policy against a local server. The only differences are the unfetchablehttp(s)://URLs.🤖 Generated with Claude Code