Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

another ?lng fix

Blue Mousefd4c68cb6993
diff --git a/app/root.tsx b/app/root.tsx
index b0990bdd5..75659cf2a 100644
--- a/app/root.tsx
+++ b/app/root.tsx
@@ -180,12 +180,23 @@ export function ErrorBoundary() {
)
}
+// Let's keep it for a few months to fix the Google Search Console ?lng= issue due to a fucking bug I introduced before
+const removeMultipleLngParams = (url: string): string => {
+ return _replace(url, /%3Flng%3D[^%]*/g, '')
+}
+
export async function loader({ request }: LoaderArgs) {
const { url } = request
+ const removedLng = removeMultipleLngParams(url)
+
+ if (removedLng !== url) {
+ return redirect(removedLng, 301)
+ }
+
const urlObject = new URL(url)
if (!isSelfhosted && isWWW(urlObject)) {
- const nonWWWLink = _replace(urlObject.href, 'www.', '')
+ const nonWWWLink = _replace(url, 'www.', '')
const httpToHttps = _replace(nonWWWLink, 'http://', 'https://')
return redirect(httpToHttps, 301)
}