Skip to content

Commit

Permalink
handle url / string properly
Browse files Browse the repository at this point in the history
  • Loading branch information
srt32 committed May 24, 2024
1 parent fe7b0a2 commit f65d3b5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/auto-check-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,12 +261,12 @@ async function check(autoCheckElement: AutoCheckElement) {
}

const body = new FormData()
const url = new URL(src, window.location.origin)
if (httpMethod === 'POST') {
body.append(csrfField, csrf)
body.append('value', input.value)
} else {
this.url = new URL(src, window.location.origin)
this.url.search = new URLSearchParams({value: input.value}).toString()
url.search = new URLSearchParams({value: input.value}).toString()
}

input.dispatchEvent(new AutoCheckSendEvent(body))
Expand All @@ -280,7 +280,7 @@ async function check(autoCheckElement: AutoCheckElement) {
state.controller = makeAbortController()

try {
const response = await fetchWithNetworkEvents(autoCheckElement, src, {
const response = await fetchWithNetworkEvents(autoCheckElement, url.toString(), {
credentials: 'same-origin',
signal: state.controller.signal,
method: httpMethod,
Expand Down

0 comments on commit f65d3b5

Please sign in to comment.