mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-08-12 03:22:46 +00:00
basic validation added to router utils path param
This commit is contained in:
parent
8fe3b1ae69
commit
0a97a9be9a
3 changed files with 9 additions and 6 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
|
|
|
|||
Loading…
Reference in a new issue