I am working with a grails app. I need to extract only part of the url up to .com (or gov, edu, mil, org, net, etc.) from a string.
For example:
Input: https://stackoverflow.com/questions?=34354#es4 Output: https://stackoverflow.com/
Input: https://code.google.com/p/crawler4j/issues/detail?id=174 Output: https://code.google.com/
Can anyone suggest how it can be done? Also, if it can be done, I need to change https to http in the resulting string. Please help. Thanks.
Edit: I apologize to all the downvoters that I did not include the thing that I tried. This is what i tried:
URL url = new URL(website);
String webUrl = url.getprotocol()+"://"+url.getAuthority()
But I got the following error: MissingPropertyException occurred when processing request: [POST] /mypackage/resource/crawl