Glodenox / twitch-chat-monitor

Twitch Chat Monitor that allows the chat to be shown comfortably on a big monitor. Useful for room-scale streaming where the chat needs to be readable from a distance.
40 stars 11 forks source link

Improve image detection #48

Open Glodenox opened 1 year ago

Glodenox commented 1 year ago

URLs like https://i0.wp.com/mediachomp.com/wp-content/uploads/2022/05/moose-dive-comic-03.jpg?resize=650%2C651&ssl=1 should still be detected as an image URL. Either due to the query params or the "%2C", this is not detected as an image.

Ideally, there's a way to check the presence of an image for every link that doesn't end with a slash. But I suspect that will cause quite a few unnecessary network calls.

Glodenox commented 1 week ago

URLs can be parsed with the JavaScript URL object, which then allows checking the pathfile contents without the query parts.

Additionally, this is a good time to clean up that code from "yay, it works, ship it" to "I could easily support other image hosting sites here".