I want to achieve something like this. If I give input as like this before
const partofurls = {
protocol: 'https',
host: 'hosturl',
port: 8080,
endpoint: 'someendpoint',
queryparams: {
key1:value1,
key2:value2
}
}
I want to get the URL as below
https://hosturl:8080/endpoint?key1=value1&key2=value2
In javascript or reactjs is there any way to achieve this?
I am getting these fields from the user. If the user added slash '/' at the end of the hosturl and if they have added the '/' at the beginning of endpoint also, then I will end up having two slashes in between hosturl and endpoint. Like this there are many other cases.
To resolve all these problems, is there any standard module or library available in reactjs or javascript?