Skip to content

Commit

Permalink
Remove www redirection logic
Browse files Browse the repository at this point in the history
www subdomain has been removed altogether.

This reverts commit b451ac3.
  • Loading branch information
silvenon committed Aug 22, 2023
1 parent 3111049 commit 368beba
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
4 changes: 2 additions & 2 deletions app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import NavBar from "./components/NavBar";

import { AnalyticsProvider, AnalyticsScript } from "~/services/analytics";

import { removeWww, removeTrailingSlash, getDomainUrl } from "~/utils";
import { removeTrailingSlash, getDomainUrl } from "~/utils";

export async function loader({ request }: LoaderArgs) {
let desiredUrl = removeTrailingSlash(removeWww(request.url));
const desiredUrl = removeTrailingSlash(request.url);

if (request.url !== desiredUrl) {
throw redirect(desiredUrl, { status: 301 });
Expand Down
8 changes: 0 additions & 8 deletions app/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,6 @@ export function getDomainUrl(request: Request) {
return `${protocol}://${host}`;
}

export function removeWww(href: string): string {
const url = new URL(href);
if (url.hostname.startsWith("www.")) {
url.hostname = url.hostname.replace(/^www\./, "");
}
return url.href;
}

export function removeTrailingSlash(href: string): string {
const url = new URL(href);
if (url.pathname.endsWith("/") && url.pathname !== "/") {
Expand Down

0 comments on commit 368beba

Please sign in to comment.