mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #465] [MERGED] fix: handle URL objects in metadata resolveUrl #592
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#592
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/465
Author: @benfavre
Created: 3/11/2026
Status: ✅ Merged
Merged: 3/12/2026
Merged by: @james-elicx
Base:
main← Head:fix/metadata-resolve-url-objects📝 Commits (6)
77691e8fix: handle URL objects in metadata resolveUrlb554103Merge remote-tracking branch 'origin/main' into fix/metadata-resolve-url-objects7e3cdeafix: update Metadata types and rendering to accept string | URL fields3e7a0d4fmtb6369c3fix: remove dead-code ?? fallbacks and unnecessary test castsab4eef0fmt📊 Changes
2 files changed (+71 additions, -77 deletions)
View changed files
📝
packages/vinext/src/shims/metadata.tsx(+57 -77)📝
tests/features.test.ts(+14 -0)📄 Description
Problem
The
resolveUrl()function insideMetadataHeadonly acceptsstring, but the Next.js Metadata API types several URL fields asstring | URL:metadataBaseis typed asURL | null(and is already handled correctly as the base)openGraph.url, icon URLs, manifest, alternates, etc. all acceptstring | URLper Next.js typesWhen a
URLobject is passed (which is valid per Next.js API),resolveUrl()calls.startsWith()on it, which crashes:Solution
Add type coercion at the top of
resolveUrl():Changes
packages/vinext/src/shims/metadata.tsxresolveUrlparameter type fromstring | undefinedtostring | URL | undefinedURL→.toString(), other non-string truthy values →String(url)sReproduction
Risk
Minimal — purely additive type coercion. String inputs follow the exact same code path as before.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.