diff --git a/src/router/Router/queryParamsForQuery.js b/src/router/Router/queryParamsForQuery.js index a242aac39..ed5b19bb1 100644 --- a/src/router/Router/queryParamsForQuery.js +++ b/src/router/Router/queryParamsForQuery.js @@ -1,5 +1,6 @@ module.exports = (query) => { - return Array.from(new URLSearchParams(query).entries()) + const searchParams = new URLSearchParams(typeof query === 'string' ? query : ''); + return Array.from(searchParams.entries()) .reduce((result, [key, value]) => { result[key] = value; return result; diff --git a/src/router/Router/routeConfigForPath.js b/src/router/Router/routeConfigForPath.js index dc11bbf0f..841e3424d 100644 --- a/src/router/Router/routeConfigForPath.js +++ b/src/router/Router/routeConfigForPath.js @@ -1,8 +1,10 @@ module.exports = (viewsConfig, path) => { - for (const viewConfig of viewsConfig) { - for (const routeConfig of viewConfig) { - if (path.match(routeConfig.regexp)) { - return routeConfig; + if (typeof path === 'string') { + for (const viewConfig of viewsConfig) { + for (const routeConfig of viewConfig) { + if (path.match(routeConfig.regexp)) { + return routeConfig; + } } } } diff --git a/src/router/Router/urlParamsForPath.js b/src/router/Router/urlParamsForPath.js index a431c2801..d7b52aaea 100644 --- a/src/router/Router/urlParamsForPath.js +++ b/src/router/Router/urlParamsForPath.js @@ -1,5 +1,5 @@ module.exports = (routeConfig, path) => { - const matches = path.match(routeConfig.regexp); + const matches = typeof path === 'string' ? path.match(routeConfig.regexp) : []; return routeConfig.urlParamsNames.reduce((urlParams, name, index) => { if (Array.isArray(matches) && typeof matches[index + 1] === 'string') { urlParams[name] = matches[index + 1];