Reputation:
How can I remove the URL from a string but keep the path only?
I just want to keep the path only but API returns FULL URL only.
MainMenu.jsx:47 http://dev.ffbvps.local/about/
MainMenu.jsx:47 http://dev.ffbvps.local/work/
MainMenu.jsx:47 http://dev.ffbvps.local/behind-the-scenes/
MainMenu.jsx:47 http://dev.ffbvps.local/people/
MainMenu.jsx:47 http://dev.ffbvps.local/themes/
Upvotes: 0
Views: 788
Reputation: 13
let url
let urlObjPath = new URL("http://dev.ffbvps.local/behind-the-scenes/").pathname;
console.log(urlObjPath);
Upvotes: 0
Reputation: 989
const paramUrl = new URL("http://dev.ffbvps.local/about/");
console.log(paramUrl.pathname)
Upvotes: 1
Reputation: 373
If you want to have the pathname, you can use:
window.location.pathname
Upvotes: 0