Skip to content
Myr

fix(client): handle query parameters in `removeIndexString` (#4352)

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

* fix(client): handle query parameters in `removeIndexString` * fix the typo

authored by Yusuke Wada · committed by GitHub · parent 193d5dc · Browse files · 3 files+30 added−4 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+30 added−4 removed

  • tests:+26 added−0 removed
  • other:+4 added−4 removed

3 files+30 added−4 removed

modified:src/client/client.test.ts+8 added
354 unmodified lines
355356 it('Should return a correct url via $url().href', async () => {357 const client = hc<typeof app>('http://fake')358 expect(client.index.$url().href).toBe('http://fake/')359 expect(360 client.index.$url({361 query: {362 page: '123',363 limit: '20',364 },365 }).href366 ).toBe('http://fake/?page=123&limit=20')367 expect(client.api.$url().href).toBe('http://fake/api')368 expect(369 client.api.posts[':id'].$url({370 param: {
1011 unmodified lines
modified:src/client/utils.test.ts+18 added
120 unmodified lines
121 url = '/subindex'122 newUrl = removeIndexString(url)123 expect(newUrl).toBe('/subindex')124 })125126 it('Should remove `/index` with query parameters', () => {127 let url = 'http://localhost/index?page=123&limit=20'128 let newUrl = removeIndexString(url)129 expect(newUrl).toBe('http://localhost/?page=123&limit=20')130131 url = 'https://example.com/index?q=search'132 newUrl = removeIndexString(url)133 expect(newUrl).toBe('https://example.com/?q=search')134135 url = '/api/index?filter=test'136 newUrl = removeIndexString(url)137 expect(newUrl).toBe('/api?filter=test')138139 url = '/index?a=1&b=2&c=3'140 newUrl = removeIndexString(url)141 expect(newUrl).toBe('?a=1&b=2&c=3')142 })143})144145describe('deepMerge', () => {146 it('should return the source object if the target object is not an object', () => {
192 unmodified lines
modified:src/client/utils.ts+4 added-4 removed