Skip to content

Commit

Permalink
chore: remove unused trailing slash utility (#3280)
Browse files Browse the repository at this point in the history
  • Loading branch information
BobbieGoede authored Dec 24, 2024
1 parent 1262163 commit 4d93e07
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 52 deletions.
8 changes: 0 additions & 8 deletions src/runtime/routing/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@ export function getNormalizedLocales(locales: Locale[] | LocaleObject[]): Locale
return normalized
}

export function adjustRoutePathForTrailingSlash(
pagePath: string,
trailingSlash: boolean,
isChildWithRelativePath: boolean
) {
return pagePath.replace(/\/+$/, '') + (trailingSlash ? '/' : '') || (isChildWithRelativePath ? '' : '/')
}

export function getRouteName(routeName?: string | symbol | null) {
if (isString(routeName)) return routeName
if (isSymbol(routeName)) return routeName.toString()
Expand Down
44 changes: 0 additions & 44 deletions test/routing-utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,50 +1,6 @@
import { describe, it, assert, test } from 'vitest'
import * as utils from '../src/runtime/routing/utils'

describe('adjustRouteDefinitionForTrailingSlash', function () {
describe('pagePath: /foo/bar', function () {
describe('trailingSlash: false, isChildWithRelativePath: true', function () {
it('should be trailed with slash: /foo/bar/', function () {
assert.equal(utils.adjustRoutePathForTrailingSlash('/foo/bar', true, true), '/foo/bar/')
})
})

describe('trailingSlash: false, isChildWithRelativePath: true', function () {
it('should not be trailed with slash: /foo/bar/', function () {
assert.equal(utils.adjustRoutePathForTrailingSlash('/foo/bar', false, true), '/foo/bar')
})
})

describe('trailingSlash: false, isChildWithRelativePath: false', function () {
it('should be trailed with slash: /foo/bar/', function () {
assert.equal(utils.adjustRoutePathForTrailingSlash('/foo/bar', true, false), '/foo/bar/')
})
})

describe('trailingSlash: false, isChildWithRelativePath: false', function () {
it('should not be trailed with slash: /foo/bar/', function () {
assert.equal(utils.adjustRoutePathForTrailingSlash('/foo/bar', false, false), '/foo/bar')
})
})
})

describe('pagePath: /', function () {
describe('trailingSlash: false, isChildWithRelativePath: true', function () {
it('should not be trailed with slash: empty', function () {
assert.equal(utils.adjustRoutePathForTrailingSlash('/', false, true), '')
})
})
})

describe('pagePath: empty', function () {
describe('trailingSlash: true, isChildWithRelativePath: true', function () {
it('should not be trailed with slash: /', function () {
assert.equal(utils.adjustRoutePathForTrailingSlash('', true, true), '/')
})
})
})
})

describe('getLocaleRouteName', () => {
describe('strategy: prefix_and_default', () => {
it('should be `route1___en___default`', () => {
Expand Down

0 comments on commit 4d93e07

Please sign in to comment.