Skip to content

Commit aa8ac71

Browse files
committed
1 parent a28474c commit aa8ac71

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

lib/fetchGhContent.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
const fetch = require('node-fetch')
2-
const utf8 = require('utf8')
32

4-
const decodeBase64 = (encoded) => Buffer.from(encoded, 'base64').toString('ascii')
5-
const decode = (encoded) => utf8.decode(decodeBase64(encoded))
3+
const decode = (encoded) => Buffer.from(encoded, 'base64').toString()
64

75
const buildApiUrl = ({ owner, repo, path, token, ref }) => {
86
if (!owner) {

package-lock.json

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
"url": "https://github.com/FujiHaruka/fetch-github-content/issues"
77
},
88
"dependencies": {
9-
"node-fetch": "^2.6.0",
10-
"utf8": "^3.0.0"
9+
"node-fetch": "^2.6.0"
1110
},
1211
"devDependencies": {
1312
"mocha": "^6.2.0"

test/fetchGhContent.test.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,23 @@ describe('fetchGhContent', function() {
1616
})
1717

1818
it('json option', async () => {
19-
const pkg = await fetchGhContent({
19+
const json = await fetchGhContent({
20+
owner: 'FujiHaruka',
21+
repo: 'fetch-github-content',
22+
path: 'test/data/foo.json',
23+
json: true,
24+
})
25+
assert.equal(json.name, 'fetch-github-content')
26+
})
27+
28+
it('unicode', async () => {
29+
const json = await fetchGhContent({
2030
owner: 'FujiHaruka',
2131
repo: 'fetch-github-content',
22-
path: 'package.json',
32+
path: 'test/data/unicode.json',
2333
json: true,
2434
})
25-
assert.equal(pkg.name, 'fetch-github-content')
35+
assert.equal(json.name, 'ユニコードにも対応する')
2636
})
2737

2838
it('throws error if required fields are lack', async () => {

0 commit comments

Comments
 (0)