Skip to content

Commit

Permalink
chore(upload-client): skip coverage for browser-only code
Browse files Browse the repository at this point in the history
  • Loading branch information
talentlessguy committed Feb 20, 2025
1 parent f00abea commit bbe5bef
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/upload-client/src/fetch-with-upload-progress.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ const withUploadProgress = (options) => {
}

// HTTP/1.1 and browsers

/* c8 ignore start */
/**
*
* @param {string} url
Expand Down Expand Up @@ -127,13 +129,14 @@ const fetchXhr = (url, { onUploadProgress, ...init }) => {
}
}

/* c8 ignore stop */

// Deno supports H1 streaming
const isNode =
typeof process !== 'undefined' &&
process.versions.node &&
!process.versions.bun &&
!process.versions.deno
// const isDeno = typeof process !== 'undefined' && process.versions.deno
// const isBun = typeof process !== 'undefined' && process.versions.bun
const isBrowser = typeof globalThis.XMLHttpRequest !== 'undefined'

/**
Expand All @@ -149,6 +152,8 @@ export const fetchWithUploadProgress = (url, init = {}) => {
performance.getEntriesByType('resource')[0]?.nextHopProtocol
const preH2 = protocol !== 'h2' && protocol !== 'h2c' && protocol !== 'h3'


/* c8 ignore next 3 */
if ((isBrowser || preH2) && !isNode) {
return fetchXhr(url, init)
}
Expand Down

0 comments on commit bbe5bef

Please # to comment.