mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-04-05 00:10:16 +00:00
16 lines
523 B
JavaScript
16 lines
523 B
JavaScript
// Copyright (C) 2017-2023 Smart code 203358507
|
|
|
|
const urlParamsForPath = (routeConfig, path) => {
|
|
const matches = path.match(routeConfig.regexp);
|
|
return routeConfig.urlParamsNames.reduce((urlParams, name, index) => {
|
|
if (Array.isArray(matches) && typeof matches[index + 1] === 'string') {
|
|
urlParams[name] = decodeURIComponent(matches[index + 1]);
|
|
} else {
|
|
urlParams[name] = null;
|
|
}
|
|
|
|
return urlParams;
|
|
}, { path });
|
|
};
|
|
|
|
module.exports = urlParamsForPath;
|