I'm trying to figure out how to get a portion of the url in a Master Page in SharePoint 2016 on-prem. For example, I have several site collections that look like this:
http://mainsite.domain.com/sites/test1/... http://mainsite.domain.com/sites/test2/...
In a master page, how do I trim off everything after the .com to end up with a url that looks like this: