Skip to content

Commit

Permalink
fixed URL resolving for same URL in browser
Browse files Browse the repository at this point in the history
  • Loading branch information
liborm85 committed Jan 3, 2025
1 parent 507314d commit 9974c93
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Unreleased

- Fixed URL resolving for same URL in browser

## 0.3.0-beta.15 - 2025-01-01

- Reverted to the original `pdfkit` package, moving away from `@foliojs-fork`
Expand Down
15 changes: 10 additions & 5 deletions src/browser-extensions/URLBrowserResolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,17 @@ class URLBrowserResolver {
if (!this.resolving[url]) {
this.resolving[url] = new Promise((resolve, reject) => {
if (url.toLowerCase().indexOf('https://') === 0 || url.toLowerCase().indexOf('http://') === 0) {
fetchUrl(url, headers).then(buffer => {
this.fs.writeFileSync(url, buffer);
if (this.fs.existsSync(url)) {
// url was downloaded earlier
resolve();
}, result => {
reject(result);
});
} else {
fetchUrl(url, headers).then(buffer => {
this.fs.writeFileSync(url, buffer);
resolve();
}, result => {
reject(result);
});
}
} else {
// cannot be resolved
resolve();
Expand Down

0 comments on commit 9974c93

Please sign in to comment.