I need your help.
I have this link: https://domen.org/bbb/bb/bb/uniqueID
the link may change, but the unique id is always at the end
I'm use: window.location.pathname.split('/')[2]
but since the length of the link changes, I can't catch it all the time, how can I optimize this?
I only need to get the last link ID example: https://domen.org/bb/uniqueID
Asked
Active
Viewed 12 times
0
-
2`const id = window.location.pathname.split('/').pop()`? – Andy Oct 23 '22 at 22:02
-
Note: nodeJs doesn't have a `window`. – Andy Oct 23 '22 at 22:04
-
@Andy, yeah sorry, thanks reply – user20317378 Oct 23 '22 at 22:05
-
What is “extreme” about this? How is this related to optimization? – Sebastian Simon Oct 23 '22 at 22:05
-
@SebastianSimon, I don't know – user20317378 Oct 23 '22 at 22:06