Is this safe to use require(\"path\").join
to concatenate URLs, for example:
require(\"path\").join(\"http://example.com\", \"ok\");
//returns
When I tried PATH for concatenating url parts I run into problems.
PATH.join
stripes '//' down to '/' and this way invalidates an absolute url (eg. http://... -> http:/...).
For me a quick fix was:
baseurl.replace(/\/$/,"") + '/' + path.replace(/^\//,"") )
or with the solution posted by Colonel Panic:
[pathA.replace(/^\/|\/$/g,""),pathB.replace(/^\/|\/$/g,"")].join("/")