feat: Ensure Method In Endpoint (#2083)

This commit is contained in:
Rishabh Agarwal
2022-01-24 16:22:24 +05:30
committed by GitHub
parent aae2dac588
commit 78693964d8

View File

@@ -307,6 +307,8 @@ const newSendRequest = async () => {
return
}
ensureMethodInEndpoint()
loading.value = true
// Double calling is because the function returns a TaskEither than should be executed
@@ -345,6 +347,17 @@ const newSendRequest = async () => {
}
}
const ensureMethodInEndpoint = () => {
if (!/^http[s]?:\/\//.test(newEndpoint.value)) {
const domain = newEndpoint.value.split(/[/:#?]+/)[0]
if (domain === "localhost" || /([0-9]+\.)*[0-9]/.test(domain)) {
setRESTEndpoint("http://" + newEndpoint.value)
} else {
setRESTEndpoint("https://" + newEndpoint.value)
}
}
}
const onPasteUrl = (e: { event: ClipboardEvent; previousValue: string }) => {
if (!e) return