refactor clean url

This commit is contained in:
Marc-Roig 2022-08-09 11:43:54 +02:00
parent fce7a9112a
commit 10ea1e4ea2

View File

@ -7,14 +7,7 @@ import { typeFromMime } from './typeFromMime';
* Remove them to have a clean URL instead to use as a filename. * Remove them to have a clean URL instead to use as a filename.
*/ */
function cleanUrl(url) { function cleanUrl(url) {
// Break URL at ? and take first part (file name, extension) return new URL(url).pathname.substring(1);
url = url.split('?')[0];
// Sometimes URL doesn't have ? but #
url = url.split('#')[0];
// Cleaned URL
return url;
} }
export const urlsToAssets = async urls => { export const urlsToAssets = async urls => {