diff options
Diffstat (limited to 'src/client/util/History.ts')
-rw-r--r-- | src/client/util/History.ts | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/src/client/util/History.ts b/src/client/util/History.ts index b500a5af9..52d0223d5 100644 --- a/src/client/util/History.ts +++ b/src/client/util/History.ts @@ -1,3 +1,9 @@ +/* eslint-disable no-use-before-define */ +/* eslint-disable no-empty */ +/* eslint-disable no-continue */ +/* eslint-disable guard-for-in */ +/* eslint-disable no-restricted-syntax */ +/* eslint-disable no-param-reassign */ import * as qs from 'query-string'; import { Doc } from '../../fields/Doc'; import { OmitKeys, ClientUtils } from '../../ClientUtils'; @@ -32,6 +38,7 @@ export namespace HistoryUtil { case 'doc': onDocUrl(url); break; + default: } } } @@ -124,11 +131,11 @@ export namespace HistoryUtil { const val = customParser(pathname, opts, current); if (val === null) { return undefined; - } else if (val === undefined) { + } + if (val === undefined) { return current; - } else { - return val; } + return val; } return current; }; @@ -142,26 +149,27 @@ export namespace HistoryUtil { } const queryObj = OmitKeys(state, keys).extract; const query: any = {}; - Object.keys(queryObj).forEach(key => (query[key] = queryObj[key] === null ? null : JSON.stringify(queryObj[key]))); + Object.keys(queryObj).forEach(key => { + query[key] = queryObj[key] === null ? null : JSON.stringify(queryObj[key]); + }); const queryString = qs.stringify(query); return path + (queryString ? `?${queryString}` : ''); }; } addParser('doc', {}, { readonly: true, initializers: true, nro: true, sharing: true }, (pathname, opts, current) => { - if (pathname.length !== 2) return undefined; - - current.initializers = current.initializers || {}; - const docId = pathname[1]; - current.docId = docId; - }); - addStringifier('doc', ['initializers', 'readonly', 'nro'], (state, current) => { - return `${current}/${state.docId}`; + if (pathname.length === 2) { + current.initializers = current.initializers || {}; + const docId = pathname[1]; + current.docId = docId; + } + return undefined; }); + addStringifier('doc', ['initializers', 'readonly', 'nro'], (state, current) => `${current}/${state.docId}`); export function parseUrl(location: Location | URL): ParsedUrl | undefined { const pathname = location.pathname.substring(1); - const search = location.search; + const { search } = location; const opts = search.length ? qs.parse(search, { sort: false }) : {}; const pathnameSplit = pathname.split('/'); |