Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-docs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Read <eread@gitlab.com>2023-03-29 02:53:59 +0300
committerEvan Read <eread@gitlab.com>2023-03-29 02:53:59 +0300
commit7300a945653d8afc686d070fd81cdd5701a74cdb (patch)
treea85e85af72b754055985d85971dd35e94c61d06b
parent49aeff4b7c0e412d65d0cb703e75be0b758672f4 (diff)
parentcb03cd9386e3f761238e8ecbbeeba91811a75868 (diff)
Merge branch 'axil-fix-canonical-urls-sed' into 'main'
Do not normalize canonical URLs Closes #1568 See merge request https://gitlab.com/gitlab-org/gitlab-docs/-/merge_requests/3677 Merged-by: Evan Read <eread@gitlab.com> Approved-by: Evan Read <eread@gitlab.com> Approved-by: Sarah German <sgerman@gitlab.com> Co-authored-by: Achilleas Pipinellis <axil@gitlab.com>
-rwxr-xr-xscripts/normalize-links.sh23
1 files changed, 14 insertions, 9 deletions
diff --git a/scripts/normalize-links.sh b/scripts/normalize-links.sh
index 69eff755..417c1bd0 100755
--- a/scripts/normalize-links.sh
+++ b/scripts/normalize-links.sh
@@ -78,17 +78,22 @@ find "${TARGET}/$VER" -type f -name '*.css' -print0 | xargs -0 "$SED" -i 's|/ass
printf "${COLOR_GREEN}INFO: Replacing relative URLs in $TARGET/$VER for JavaScript files...${COLOR_RESET}\n"
find "${TARGET}/$VER" -type f -name '*.js' -print0 | xargs -0 "$SED" -i -e 's|/search/|/'"$VER"'/search/|g' \
-e 's|/assets/|/'"$VER"'/assets/|g'
-##
-## Full URLs
-##
-
+#
+# Full URLs
+#
+# We exclude the following occurrences from sed that are used to determine the
+# canonical URL:
+# - rel="canonical"
+# - property="og:url"
+# See https://gitlab.com/gitlab-org/gitlab-docs/-/issues/1568
+#
# shellcheck disable=2059
printf "${COLOR_GREEN}INFO: Replacing full URLs in $TARGET/$VER for HTML files...${COLOR_RESET}\n"
-find "${TARGET}/$VER" -type f -name '*.html' -print0 | xargs -0 "$SED" -i -e 's|href="https://docs.gitlab.com/ee/|href="/'"$VER"'/ee/|g' \
- -e 's|href="https://docs.gitlab.com/runner/|href="/'"$VER"'/runner/|g' \
- -e 's|href="https://docs.gitlab.com/omnibus/|href="/'"$VER"'/omnibus/|g' \
- -e 's|href="https://docs.gitlab.com/charts/|href="/'"$VER"'/charts/|g' \
- -e 's|href="https://docs.gitlab.com/operator/|href="/'"$VER"'/operator/|g'
+find "${TARGET}/$VER" -type f -name '*.html' -print0 | xargs -0 "$SED" -i -e '/\(rel="canonical"\|property="og:url"\)/! s|href="https://docs.gitlab.com/ee/|href="/'"$VER"'/ee/|g' \
+ -e '/\(rel="canonical"\|property="og:url"\)/! s|href="https://docs.gitlab.com/runner/|href="/'"$VER"'/runner/|g' \
+ -e '/\(rel="canonical"\|property="og:url"\)/! s|href="https://docs.gitlab.com/omnibus/|href="/'"$VER"'/omnibus/|g' \
+ -e '/\(rel="canonical"\|property="og:url"\)/! s|href="https://docs.gitlab.com/charts/|href="/'"$VER"'/charts/|g' \
+ -e '/\(rel="canonical"\|property="og:url"\)/! s|href="https://docs.gitlab.com/operator/|href="/'"$VER"'/operator/|g'
# shellcheck disable=2059
printf "${COLOR_GREEN}INFO: Fixing URLs inside the sitemap...${COLOR_RESET}\n"