@primer/blueprints
Advanced tools
Comparing version 0.0.0-af9371b to 0.0.0-d742a25
{ | ||
"name": "@primer/blueprints", | ||
"version": "0.0.0-af9371b", | ||
"version": "0.0.0-d742a25", | ||
"description": "Components for GitHub Documentation Sites", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.umd.js", |
@@ -31,1 +31,14 @@ import Router from 'next/router' | ||
} | ||
export function redirectTrailingSlash(context, status = 301) { | ||
const { | ||
req: {url}, | ||
res | ||
} = context | ||
if (url.endsWith('/')) { | ||
const withoutSlash = url.substr(0, url.length - 1) | ||
res.writeHead(status, {Location: withoutSlash}) | ||
res.end() | ||
return true | ||
} | ||
} |
97534
2835