Skip to content

Commit

Permalink
Merge pull request #33723 from github/repo-sync
Browse files Browse the repository at this point in the history
Repo sync
  • Loading branch information
docs-bot committed Jun 26, 2024
2 parents aed90a6 + afe6eef commit 3b9d172
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/frame/middleware/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ import favicons from './favicons'
import setStaticAssetCaching from '@/assets/middleware/static-asset-caching'
import fastHead from './fast-head'
import fastlyCacheTest from './fastly-cache-test'
import trailingSlashes from './trailing-slashes.js'
import trailingSlashes from './trailing-slashes'
import fastlyBehavior from './fastly-behavior.js'
import mockVaPortal from './mock-va-portal.js'
import dynamicAssets from '@/assets/middleware/dynamic-assets.js'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import type { Response, NextFunction } from 'express'

import type { ExtendedRequest } from '@/types'
import { defaultCacheControl } from './cache-control.js'

export default function trailingSlashes(req, res, next) {
export default function trailingSlashes(req: ExtendedRequest, res: Response, next: NextFunction) {
if (req.method === 'GET' || req.method === 'HEAD' || req.method === 'OPTIONS') {
const split = req.url.split('?')
let pathname = split.shift()
if (pathname !== '/' && pathname.endsWith('/')) {
if (pathname && pathname !== '/' && pathname.endsWith('/')) {
while (pathname.endsWith('/')) {
pathname = pathname.slice(0, pathname.length - 1)
}
Expand Down

0 comments on commit 3b9d172

Please sign in to comment.