Skip to content

Commit

Permalink
To return the cached file only if the cacheBurst is false
Browse files Browse the repository at this point in the history
  • Loading branch information
uramacharles committed Dec 6, 2023
1 parent de875e4 commit 0fb2242
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/dataurl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,15 @@ export async function resourceToDataURL(
options.includeQueryParams,
)

if (cache[cacheKey] != null) {
return cache[cacheKey]
}


// ref: https://developer.mozilla.org/en/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest#Bypassing_the_cache
if (options.cacheBust) {
// eslint-disable-next-line no-param-reassign
resourceUrl += (/\?/.test(resourceUrl) ? '&' : '?') + new Date().getTime()
}else{
if (cache[cacheKey] != null) {
return cache[cacheKey]
}
}

let dataURL: string
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export async function toSvg<T extends HTMLElement>(
): Promise<string> {
const { width, height } = getImageSize(node, options)
const clonedNode = (await cloneNode(node, options, true)) as HTMLElement
await embedWebFonts(clonedNode, options)
await embedImages(clonedNode, options)
await embedWebFonts(clonedNode, options)
applyStyle(clonedNode, options)
const datauri = await nodeToDataURL(clonedNode, width, height)
return datauri
Expand Down

0 comments on commit 0fb2242

Please sign in to comment.