我需要一个JS正则表达式来弹出URL的最后一部分。但是,如果它只是域名,比如http://google.com,我不想改变任何东西。
以下是示例。非常感谢您的帮助。
http://google.com -> http://google.com
http://google.com/ -> http://google.com
http://google.com/a -> http://google.com
http://google.com/a/ -> http://google.com/a
http://domain.com/subdir/ -> http://domain.com/subdir
http://domain.com/subfile.extension -> http://domain.com
http://domain.com/subfilewithnoextension -> http://domain.com