fix lint and add changelog

This commit is contained in:
Michael Schramm 2020-07-17 10:28:57 +02:00
parent 39c8296c61
commit 78cadf0942
2 changed files with 13 additions and 12 deletions

View File

@ -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

View File

@ -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
}