I'm trying to validate if a URL ends with .png:
/.[a-zA-z]\.(png)$/i
However, it doesn't seem to be working when using it as a value for a pattern attribute, but everything seems to be fine here (regex101.com).
<form action="#">
<input type="url" pattern="/.[a-zA-z]\.(png)$/i" value="" required >
<input type="submit" value="submit"/>
</form>
A test string to validate:
http://imgur.com/foo.png
I want to match o.png or everything after the last forward slash and ends with a .png
gflag for "ends with".console.log(/\.png$/.test('adasdaads.png'))\.png$-- the rest of the regex is unnecessary..png?width=200. and serve it as jpeg or webp (depending on accept header) I think you should accept any url, make a (head or normal) request and check if the content-type is image/png and possible abort the request