Skip to content
This repository has been archived by the owner on Dec 2, 2023. It is now read-only.

Commit

Permalink
fix lint and add changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
wodka committed Jul 17, 2020
1 parent 39c8296 commit 78cadf0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- do not show login note if it is not set
- typo in dropdown options https://github.com/ohmyform/ohmyform/issues/96
- query parms are not parsed https://github.com/ohmyform/ui/pull/27 https://github.com/ohmyform/ohmyform/issues/100
- errors because of missing user reference (https://github.com/ohmyform/ohmyform/issues/102)

### Security

Expand Down
24 changes: 12 additions & 12 deletions components/use.router.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import React from 'react';
import {useRouter as useNextRouter} from 'next/router';
import { NextRouter, useRouter as useNextRouter } from 'next/router'

const parseQuery = (path) => {
const query = {}
const regex = /[?&]([^&$=]+)(=([^&$]+))?/g
let param: RegExpExecArray

function parseQuery(path) {
const query = {};
const regex = /[?&]([^&$=]+)(=([^&$]+))?/g;
let param;
while ((param = regex.exec(path)) !== null) {
query[decodeURIComponent(param[1])] = decodeURIComponent(param[3]);
query[decodeURIComponent(param[1])] = decodeURIComponent(param[3])
}
return query;

return query
}

export function useRouter() {
const router = useNextRouter();
router.query = {...router.query, ...parseQuery(router.asPath)};
return router;
export const useRouter = (): NextRouter => {
const router = useNextRouter()
router.query = { ...router.query, ...parseQuery(router.asPath) }
return router
}

0 comments on commit 78cadf0

Please sign in to comment.