in reply to Basic but stupid problem i cannot wrap my head around

I find it hard to believe this is the general case of what you're attempting. But if it is, both cases will be covered if you just split on / and print the first element.