Copilot commented on code in PR #2860:
URL: https://github.com/apache/tika/pull/2860#discussion_r3334247883
##########
docs/publish-docs.sh:
##########
@@ -83,6 +83,11 @@ cp target/site/404.html "${DOCS_DIR}/"
# Lunr index lives next to _/ (one level above docs/), since HTML uses
../../search-index.js.
# Remove the stale copy from its old publish/docs/ location left by earlier
runs.
rm -f "${DOCS_DIR}/search-index.js"
-cp target/site/search-index.js "${PUBLISH_DIR}/"
+# Rewrite URLs in the search index from /tika/X.Y.Z/... (Antora's component-
+# prefixed publish path) to /docs/X.Y.Z/... (the deployed layout). The HTML
+# pages and sitemap.xml above are similarly flattened; without this rewrite,
+# clicking a search result lands on https://tika.apache.org/tika/... which
+# 404s. See TIKA-4743.
+sed 's|"url":"/tika/|"url":"/docs/|g' target/site/search-index.js >
"${PUBLISH_DIR}/search-index.js"
Review Comment:
Because of shell redirection semantics, this command will truncate/create
`${PUBLISH_DIR}/search-index.js` before `sed` runs. If
`target/site/search-index.js` is missing or `sed` errors, the published search
index can be left empty even though the script exits non-zero. Consider writing
to a temporary file first (and explicitly failing with a clear message if the
input file is missing) so a failed rewrite can’t corrupt an existing published
index.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]