Use getPathname() instead of string casting