Skip to content

Commit

Permalink
fix(wpt): download files as buffer instead of text
Browse files Browse the repository at this point in the history
There are binary files in the WPT repository and downloading them as
text corrupts them.

Refs: nodejs/node#37294
  • Loading branch information
targos committed Feb 21, 2021
1 parent 059c138 commit 5479fb1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/github/tree.js
Expand Up @@ -58,10 +58,10 @@ class GitHubTree {
return `${this.repoUrl}/tree/${commit.slice(0, 10)}/${this.path}`;
}

async text(assetPath) {
async buffer(assetPath) {
await this.getLastCommit();
const url = this.getAssetUrl(assetPath);
return this.request.text(url);
return this.request.buffer(url);
}

/**
Expand Down
4 changes: 4 additions & 0 deletions lib/request.js
Expand Up @@ -37,6 +37,10 @@ class Request {
return wrappedFetch(url, options);
}

async buffer(url, options = {}) {
return this.fetch(url, options).then(res => res.buffer());
}

async text(url, options = {}) {
return this.fetch(url, options).then(res => res.text());
}
Expand Down

0 comments on commit 5479fb1

Please sign in to comment.