extract last part of a url

前端 未结 5 1766
小鲜肉
小鲜肉 2021-01-05 16:32

need the last part of the url

http://example.com then the last part is nothing if it is http://example.com/i then last part is i if it is http://example.com/i/am/fil

5条回答
  •  无人及你
    2021-01-05 17:26

    Note that Vasil's example won't work if for some reason you have a trailing slash, as for instance some CMS systems will put at the end (Magento, I'm looking at you...)

    Well, it'll work, but the end of the path is empty. Something to be aware of.

提交回复
热议问题