Reputation: 349
Hi everybody i have path on my Vue.js, so i'm need to replace /categories/.
axios ('apps/' + app.context.route.fullPath.replace('/categories/', ''))
here what i'm trying to do, but, here's the problem when i'm use this with path '/categories' without last '/', it don't work. Could you help me to match this string with regex with this two variants
Upvotes: 0
Views: 154
Reputation: 1091
The solution would be to pass a regex as the first param of the replace method like this:
axios ('apps/' + app.context.route.fullPath.replace(/\/categories\/?/, ''))
The last part of the regex \/?
means that the character /
is optional.
Which will work for /categories
and also for /categories/
.
Hope it helps!
Upvotes: 1