From 29b948197d5222e900817f201cb29abc65027343 Mon Sep 17 00:00:00 2001 From: Alex Rudenko Date: Wed, 11 Jan 2023 15:51:39 +0100 Subject: [PATCH] chore: fix website URLs (#9490) GitHub Pages appends trailing slashes which might break docusaurus links. --- website/docusaurus.config.js | 7 +++++++ website/static/fix-location.js | 5 +++++ 2 files changed, 12 insertions(+) create mode 100644 website/static/fix-location.js diff --git a/website/docusaurus.config.js b/website/docusaurus.config.js index cb9a429318e..a3825dd6fa2 100644 --- a/website/docusaurus.config.js +++ b/website/docusaurus.config.js @@ -41,6 +41,13 @@ const config = { defaultLocale: 'en', locales: ['en'], }, + scripts: [ + { + src: '/fix-location.js', + async: false, + defer: false, + }, + ], webpack: { jsLoader: isServer => { return { diff --git a/website/static/fix-location.js b/website/static/fix-location.js new file mode 100644 index 00000000000..710716d7d70 --- /dev/null +++ b/website/static/fix-location.js @@ -0,0 +1,5 @@ +const url = new URL(window.location.href); +if (url.pathname.endsWith('/') && url.pathname !== '/') { + url.pathname = url.pathname.substring(0, url.pathname.length - 1); + window.history.replaceState(null, undefined, url.toString()); +}