-
Couldn't load subscription status.
- Fork 4
Open
Description
function guessMediaType(url) {
const extensionMatch = url.match(/\.([^/.]+)$/);
if (extensionMatch === null)
return 'image';
const extension = extensionMatch[1];
// ...
}That means the plugin is currently looking for a dot . followed by anything but a dot or slash before the end of the URL. If I'm not mistaken, this should yield unwanted results in these example cases:
http://example.mov-- match ismov, which could be a recognized video file extension and is a valid TLDvideo.mp4?t=1m30s-- match ismp4?t=1m30s, notmp4as intendedaudio.mp3#chapter4-- match ismp3#chapter4, notmp3as intended
I'm not sure if it's usable yet, but URL.pathname should strip out host, query and hash automatically. Otherwise you could also consider them manually.
const extensionMatch = url.match(/\/.*\.([^/.]+)(?:\?[^?]*)?(?:#[^#]*)?$/);Metadata
Metadata
Assignees
Labels
No labels