From d377af077b80b6ca447d5b00a86695334343d9d7 Mon Sep 17 00:00:00 2001 From: ShaneK Date: Thu, 30 Apr 2026 09:14:14 -0700 Subject: [PATCH] fix(vercel): use absolute hrefs in preview dir indexes --- core/scripts/vercel-build.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/scripts/vercel-build.sh b/core/scripts/vercel-build.sh index daf44142dce..99c83b22adc 100755 --- a/core/scripts/vercel-build.sh +++ b/core/scripts/vercel-build.sh @@ -62,6 +62,12 @@ generate_dir_index() { # Skip if an index.html already exists (it's an actual test page) [ -f "${dir}/index.html" ] && return + # Absolute hrefs based on url_path. Vercel does not redirect to add trailing + # slashes, so a relative href like "basic/" from a URL without a trailing + # slash resolves against the parent directory and breaks navigation. + local parent_path="${url_path%/}" + parent_path="${parent_path%/*}/" + local entries="" for child in "${dir}"/*/; do [ -d "${child}" ] || continue @@ -70,7 +76,7 @@ generate_dir_index() { case "${name}" in *-snapshots|.*) continue ;; esac # Only include if there's at least one index.html somewhere underneath find "${child}" -name "index.html" -print -quit | grep -q . || continue - entries="${entries}${name}/\n" + entries="${entries}${name}/\n" done [ -z "${entries}" ] && return @@ -92,7 +98,7 @@ generate_dir_index() {

Index of ${url_path}

- ../ + ../ $(echo -e "${entries}")