Skip to content

Commit

Permalink
fix data url test
Browse files Browse the repository at this point in the history
fixup
  • Loading branch information
KhafraDev committed Jan 2, 2024
1 parent db635f7 commit 4fa8a62
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/fetch/dataURL.js
Original file line number Diff line number Diff line change
Expand Up @@ -630,14 +630,18 @@ function isASCIIWhitespace (char) {
* @param {boolean} [trailing=true]
*/
function removeASCIIWhitespace (str, leading = true, trailing = true) {
let i = 0; let j = str.length
let lead = 0
let trail = str.length - 1

if (leading) {
while (j > i && isASCIIWhitespace(str.charCodeAt(i))) --i
while (lead < str.length && isASCIIWhitespace(str.charCodeAt(lead))) lead++
}

if (trailing) {
while (j > i && isASCIIWhitespace(str.charCodeAt(j - 1))) --j
while (trail > 0 && isASCIIWhitespace(str.charCodeAt(trail))) trail--
}
return i === 0 && j === str.length ? str : str.substring(i, j)

return lead === 0 && trail === str.length - 1 ? str : str.slice(lead, trail + 1)
}

module.exports = {
Expand Down

0 comments on commit 4fa8a62

Please sign in to comment.