Answer the question
In order to leave comments, you need to log in
How to cut part of URL up to a certain point?
Hello!
There is a url:
http://localhost:3000/Users/user_name/projects/domain/post/image/63/dfe8b2f18890813bdfc53ed2c0982d73.png
Answer the question
In order to leave comments, you need to log in
Regulators are not needed.
Based on the resources indicated in the config/routes routes, you can find out which resource generates localhost:3000/Users/user_name/projects/domain
Then, you check if the search string is in the full path using index. If from position 0, then with a regular slice of a string array you extract a part, starting from the index of the length of the string you are looking for.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question