I want to match a particular domain and its subdomain, no matter how it's entered. In the following example, I want to match all ´test.comif nothing comes after it (only a slash or query strings) OR if a specific folder follows it in this case it's named as:subfolder`. Again the subfolder could have / or query strings after.
| Domain | Match |
|---|---|
| test.com | match |
| https://test.com | match |
| https://test.com?foo=bar | match |
| https://test.com/ | match |
| https://test.com/?foo=bar | match |
| https://www.test.com | match |
| https://www.test.com/subfolder | match |
| https://www.test.com/subfolder/ | match |
| https://www.test.com/subfolder/?foo=bar | match |
| test.com/subfolder | match |
| https://www.test.com/foo | no match |
| test.com/foo | no match |
| https://www.test.com/jason | no match |
| https://www.test.com/jason?foo=bar | no match |
Right now I have the following regex:
^(?:\S+://)?[^/]+/?$
The problem though is that it matches ANY domains, which is not what I need. I want to match a specific domain and a specific subfolder.
How is this possible?