PS: It catches undesired strings if they have a dot in the middle, for example "test.test", because it's not checking if ".test" is a real domain extension.
You can improve the solution by checking all the possible domain extensions: https://en.wikipedia.org/wiki/List_of_Internet_top-level_domains