Skip to content
Myr

fix(app): don't remove slash form `/` if strict is false (#1004)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* fix(app): don't remove slash form `/` if strict is `false` * fixed test * denoify

authored by Yusuke Wada · committed by GitHub · parent 95602a1 · Browse files · 3 files+7 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+7 added−2 removed

  • tests:+5 added−0 removed
  • other:+2 added−2 removed

3 files+7 added−2 removed

modified:deno_dist/utils/url.ts+1 added-1 removed
modified:src/utils/url.test.ts+5 added
87 unmodified lines
88 expect(path).toBe('/hello')89 path = getPathFromURL('https://example.com/hello/hey/', false)90 expect(path).toBe('/hello/hey')91 })9293 it('getPathFromURL - return `/` even if strict is false', () => {94 const path = getPathFromURL('https://example.com/', false)95 expect(path).toBe('/')96 })97 })9899 describe('getQueryStringFromURL', () => {100 it('should return strings of query params', () => {
108 unmodified lines
modified:src/utils/url.ts+1 added-1 removed
72 unmodified lines
73 const result = url.substring(url.indexOf('/', 8), queryIndex === -1 ? url.length : queryIndex)7475 // if strict routing is false => `/hello/hey/` and `/hello/hey` are treated the same76 // default is true77 if (strict === false && result.endsWith('/')) {77 if (strict === false && /.+\/$/.test(result)) {78 return result.slice(0, -1)79 }8081 return result
109 unmodified lines