How to intercept the back address from the third to the last?

I want to get the content "/ product/detail/10552" that begins with the third-to-last slash of str. How should I get it?

"http://1.2.3.4/aaa/product/detail/10552"
"https://aaa.bbb/product/detail/10552"
"http://aaa.bbb.ccc.net/product/detail/10552"
Nov.25,2021

function method(s){

return s.split("/").slice("-3").join("/")

}
Menu