I have a map like so:
const urlPaths = {
"Signature": "signature/(signatureId)",
"Rule": "signature/(signatureId)/rule/(ruleId)",
};
I then have some data that comes in my API like:
aId: {
signatureId: "999"
}
or
aId: {
signatureId: "123",
ruleId: "456"
}
I want to be able to use that map, to return me the url for Signature or Rule, for example:
"signature/999" or "signature/123/rule/456"
I've come across the regex replace, but wondering, can I actually use that in this case?
function createUrl(url, regex, aId){
url.replace(regex,(id) => aId[id])
}
Not sure if its possible/how to do with that or do I need something else?
Any ideas appreciated.
Thanks.