JSFiddle - React, Tailwind, and code Playground
HTML
<div>
First Run Control: <span id="firstCtr"></span>
</div>
<div>
Second Run Control: <span id="secondCtr"></span>
</div>
<hr/>
<div>
First Run: <span id="first"></span>
</div>
<div>
Second Run: <span id="second"></span>
</div>
JavaScript
var test = /^(((\/[\w-]+)+\/?)|(((http|ftp|https):\/\/)[\w-]+))((\.[\w-]+)?([\w.,@?^=%&lL\/~+#-]*[\w@?~=%&:\/~+#-])?)$/gi
var str = "/api/WebTest";
document.getElementById("firstCtr").innerHTML = /^(((\/[\w-]+)+\/?)|(((http|ftp|https):\/\/)[\w-]+))((\.[\w-]+)?([\w.,@?^=%&lL\/~+#-]*[\w@?~=%&:\/~+#-])?)$/gi.test(str)
document.getElementById("secondCtr").innerHTML = /^(((\/[\w-]+)+\/?)|(((http|ftp|https):\/\/)[\w-]+))((\.[\w-]+)?([\w.,@?^=%&lL\/~+#-]*[\w@?~=%&:\/~+#-])?)$/gi.test(str)
document.getElementById("first").innerHTML = test.test(str)
document.getElementById("second").innerHTML = test.test(str)