I need to verify if given URL matches my domain mask.
Example: I want to allow only domains which satisfy this “pseudo-mask”:
https://*.domain.com
http://*.domain.com
So next domains are OKAY:
http://my.domain.com/something/blah.html
https://www.domain.com/
http://domain.com/go/somewhere.html
https://very.weird.domain.com/index.jsp
but next domains are NOT OKAY:
https://domain.com.google.com/other.html
http://my.domainfake.com/haha.jsp
https://my.fakedomain.com/
(The not-
/to stop.domain.comappearing in the path, the not-@to stop username:password@ abuse.)Better, though: use the URL class built into Java to parse a URL properly. You can then just read the
hostproperty and check that itendsWithyour domain.