Skip to content

Commit

Permalink
chore: add trim to api_url within apiFetch
Browse files Browse the repository at this point in the history
ref: #18
  • Loading branch information
jon-nfc committed Dec 9, 2024
1 parent 63aa0c6 commit 8b52208
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/hooks/apiFetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@ export async function apiFetch(
metadata = true,
) {

console.debug(`apiFetch, using API_URL env variable:, ${window.env.API_URL}`)
console.debug(`apiFetch, using API_URL env variable: [${window.env.API_URL}]`)

if( String(url_path).includes(window.env.API_URL) ) { // normalise passed URLs
console.debug(`apiFetch was passed URL: [${url_path}]`)

console.debug(`url_path for function apiFetch was a full url, ${url_path}, normalizing...`)
if( String(url_path).includes(String(window.env.API_URL).trim()) ) { // normalise passed URLs

url_path = String(url_path).replace(window.env.API_URL, '')
console.debug(`url_path for function apiFetch was a full url, [${url_path}], normalizing...`)

console.debug(`normailized to ${url_path}`)
url_path = String(url_path).replace(String(window.env.API_URL).trim(), '')

console.debug(`normailized to [${url_path}]`)

}

Expand Down Expand Up @@ -141,6 +143,7 @@ export async function apiFetch(
}


console.debug(`apiFetch finished for URL: [${url_path}]`)

if(
http_method === 'PATCH'
Expand Down

0 comments on commit 8b52208

Please sign in to comment.