Skip to content

Commit

Permalink
fix: avoid double //
Browse files Browse the repository at this point in the history
  • Loading branch information
baozouai committed Jul 25, 2023
1 parent a968540 commit 0b61c9c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion playgrounds/react/src/pages/order/index.tsx
Expand Up @@ -9,7 +9,7 @@ function Order() {
<View className='index'>
<Button onClick={history.pushBind('index/index')}>跳到首页</Button>
<Button onClick={() => {
history.push('order/detail', { order_id: 'xxx123' })
history.push('/order/detail', { order_id: 'xxx123' })
}}
>跳到详情</Button>
<Button onClick={history.pushBind('order/search', { q: q || '优衣库' })}>跳到搜索</Button>
Expand Down
4 changes: 4 additions & 0 deletions src/history.ts
Expand Up @@ -90,6 +90,10 @@ export class History {

option.url += `${preChar}&${urlEncodeStr}`
}
const [path, ...res] = option.url.split('?')

// avoid double //
option.url = path.replace(/\/{2,}/, '/') + (res ? `?${res.join('')}` : '')
if (!isBlock) {
this.notifyListeners(params)
if (method === 'push')
Expand Down

0 comments on commit 0b61c9c

Please sign in to comment.