This seems kinda wrong discarding everything but the last identifier in the path, in theory you have a lot more contextual information, right?

I think this is ok for now (today's behavior is nothing!), but I am concerned about searching for empty strings.