Here is my URI.
/v1/securemessages/members/{mbruid}?folder=Inbox
I want to split this URI using javascript and pass the value of mbruid to a stored procedure.
Here is my script.
function getQueryParam(encUrl,pathverIndex){
var url,reqURIParam;
url=decodeURIComponent(encUrl);
pathVarArr = url.split('/');
reqURIParam =pathVarArr[pathverIndex];
return reqURIParam;
}
mbruid = getQueryParam(tags["encURL"],4);
The problem is that I am getting {mbruid}?folder=Inbox
instead of {mbruid}
. Please help me modify my script so the only desired variable is returned.
A few ways to do this but here's one specific to your url:
var x = url.split('?')[0].split('/').splice(-1);