Skip to content

Commit

Permalink
fix: refactor and improve localized route resolution (#3283)
Browse files Browse the repository at this point in the history
  • Loading branch information
BobbieGoede authored Dec 26, 2024
1 parent 9987394 commit df49499
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 196 deletions.
17 changes: 6 additions & 11 deletions specs/routing/routing-tests.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/// <reference types="vitest/globals" />

import { STRATEGIES } from '../../src/constants'
import type { Strategies } from '../../src/types'
import { getText, gotoPath, renderPage, waitForURL } from '../helper'
Expand Down Expand Up @@ -43,17 +45,10 @@ export async function localePathTests(strategy: Strategies) {
expect(await getText(page, '#locale-path .query-foo-string')).toEqual(prefixPath('?foo=1'))
expect(await getText(page, '#locale-path .query-foo-string-about')).toEqual(prefixPath('/about?foo=1'))
expect(await getText(page, '#locale-path .query-foo-test-string')).toEqual(prefixPath('/about?foo=1&test=2'))
if (strategy === 'no_prefix') {
// TODO: fix localePath escapes paths for `no_prefix` strategy
// unexpectedly resolves to /path/as%20a%20test?foo=bar+sentence
expect(await getText(page, '#locale-path .query-foo-path-param')).not.toEqual(
prefixPath('/path/as a test?foo=bar+sentence')
)
} else {
expect(await getText(page, '#locale-path .query-foo-path-param')).toEqual(
prefixPath('/path/as a test?foo=bar+sentence')
)
}

expect(await getText(page, '#locale-path .query-foo-path-param')).toEqual(
prefixPath('/path/as a test?foo=bar+sentence')
)
expect(await getText(page, '#locale-path .query-foo-path-param-escaped')).toEqual(
prefixPath('/path/as%20a%20test?foo=bar+sentence')
)
Expand Down
Loading

0 comments on commit df49499

Please sign in to comment.