I have a URL structure designed in RESTFUL format, for example:
GET /street/:streetName/house/:houseNumber
or GET /street/:streetName/house/listings
. The placeholders :streetName
and :houseNumber
represent specific resources. I am looking to extract the common elements from the URL for future logic operations, essentially isolating /street/house
and /street/house/listings
(remove all resource-specific parts of the URL).
I have searched for a JavaScript library to assist with this task but have not found one yet. Any suggestions?
PS: One approach I considered was using string manipulation techniques such as splitting by "/" and then concatenating the key terms while ignoring the specific resource names. However, this method does not seem very reliable.