Should use pathname instead of path, since path can also contain query string

Should use pathname instead of path, since path can also contain query string.