fix: decode base64 string to utf-8

This commit is contained in:
EnixCoda 2019-03-04 14:15:05 +08:00
parent 48c83f040c
commit 194f4e6e93
No known key found for this signature in database
GPG key ID: 6825847C88AA329A
3 changed files with 10 additions and 2 deletions

View file

@ -15,6 +15,7 @@
},
"dependencies": {
"ini": "^1.3.5",
"js-base64": "^2.5.1",
"nprogress": "^0.2.0",
"octicons": "^7.1.0",
"prop-types": "^15.6.1",
@ -24,6 +25,7 @@
"devDependencies": {
"@types/chrome": "^0.0.77",
"@types/ini": "^1.3.30",
"@types/js-base64": "^2.3.1",
"@types/node": "^11.9.4",
"@types/nprogress": "^0.0.29",
"@types/react": "^16.8.2",

View file

@ -1,4 +1,5 @@
import * as ini from 'ini'
import { Base64 } from 'js-base64'
import DOMHelper from 'utils/DOMHelper'
import treeParser from 'utils/treeParser'
import URLHelper from 'utils/URLHelper'
@ -79,7 +80,7 @@ type ParsedModule = {
function resolveGitModules(root: TreeNode, blobData: BlobData) {
if (blobData) {
if (blobData.encoding === 'base64' && blobData.content && Array.isArray(root.contents)) {
const content = atob(blobData.content)
const content = Base64.decode(blobData.content)
const parsed: Parsed = ini.parse(content)
handleParsed(root, parsed)
}

View file

@ -767,6 +767,11 @@
resolved "https://registry.yarnpkg.com/@types/ini/-/ini-1.3.30.tgz#d1485459c9fad84e937414b832a2adb649eab379"
integrity sha512-2+iF8zPSbpU83UKE+PNd4r/MhwNAdyGpk3H+VMgEH3EhjFZq1kouLgRoZrmIcmoGX97xFvqdS44DkICR5Nz3tQ==
"@types/js-base64@^2.3.1":
version "2.3.1"
resolved "https://registry.yarnpkg.com/@types/js-base64/-/js-base64-2.3.1.tgz#c39f14f129408a3d96a1105a650d8b2b6eeb4168"
integrity sha512-4RKbhIDGC87s4EBy2Cp2/5S2O6kmCRcZnD5KRCq1q9z2GhBte1+BdsfVKCpG8yKpDGNyEE2G6IqFIh6W2YwWPA==
"@types/node@^11.9.4":
version "11.9.4"
resolved "https://registry.yarnpkg.com/@types/node/-/node-11.9.4.tgz#ceb0048a546db453f6248f2d1d95e937a6f00a14"
@ -4499,7 +4504,7 @@ isstream@~0.1.2:
resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a"
integrity sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=
js-base64@^2.1.9:
js-base64@^2.1.9, js-base64@^2.5.1:
version "2.5.1"
resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-2.5.1.tgz#1efa39ef2c5f7980bb1784ade4a8af2de3291121"
integrity sha512-M7kLczedRMYX4L8Mdh4MzyAMM9O5osx+4FcOQuTvr3A9F2D9S5JXheN0ewNbrvK2UatkTRhL5ejGmGSjNMiZuw==