Improve pathname method, strip leading slashes