mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-03-13 23:06:06 +00:00
20 lines
712 B
JavaScript
20 lines
712 B
JavaScript
const UrlUtils = require('url');
|
|
const routesRegexp = require('stremio/common/routesRegexp');
|
|
|
|
const sanitizeLocationPath = (path) => {
|
|
const { href, pathname, search } = UrlUtils.parse(path);
|
|
if (typeof pathname === 'string') {
|
|
const matches = pathname.match(routesRegexp.player.regexp);
|
|
if (matches) {
|
|
if (typeof matches[2] === 'string') {
|
|
return `/player/***/***/${matches[3]}/${matches[4]}/${matches[5]}/${matches[6]}${typeof search === 'string' ? search : ''}`;
|
|
} else {
|
|
return `/player/***${typeof search === 'string' ? search : ''}`;
|
|
}
|
|
}
|
|
}
|
|
|
|
return href;
|
|
};
|
|
|
|
module.exports = sanitizeLocationPath;
|