You need to explain a lot more about what you’re doing here. if it’s react router and if you mean the filename that’s the last component of that path, then inspect the router state object, looking at the path, and get the bit you want. You’ve provided almost zero context here though, so I’m absolutely shooting in the dark; if you want good answers please put together a half sensible question.
sorry ! But it’s react router . I need to extract the name to update URL .
useLocation hook in the component (or this.props.location if you’re using classes and the withRouter HoC).
Inspect the current location object you get from that:
You can then take that object make a copy, modify what you want, then pass that location straight back –