fixed isProbablyBinary() on github import

This commit is contained in:
Steven Hugg 2019-08-27 19:27:29 -04:00
parent 59da2990b1
commit 6ac8f08e08
4 changed files with 4 additions and 4 deletions

View File

@ -161,6 +161,8 @@ TODO:
- support projects with subdirectories, file list?
- switching platform of a repo?
- make sure to flatten subdirs
- re-publish repo (bug: doesn't put all files in local repo after publishing)
- allow text/binary change
- astrocade
- keyboard shortcuts
- ctrl+alt+l on ubuntu locks screen

View File

@ -1,4 +1,3 @@
"use strict";
import { FileData, Dependency, SourceLine, SourceFile, CodeListing, CodeListingMap, WorkerError, Segment, WorkerResult } from "./workertypes";
import { getFilenamePrefix, getFolderForPath, isProbablyBinary, getBasePlatform } from "./util";

View File

@ -231,10 +231,10 @@ export class GithubService {
var path = sess.prefix + item.path;
var size = item.size;
var encoding = blob.encoding;
var isBinary = isProbablyBinary(item.path, blob);
var data = blob.content;
if (blob.encoding == 'base64') {
var bindata = stringToByteArray(atob(data));
var isBinary = isProbablyBinary(item.path, bindata);
data = isBinary ? bindata : byteArrayToUTF8(bindata);
}
if (blob.size != data.length) {

View File

@ -1,4 +1,3 @@
"use strict";
export function lpad(s:string, n:number):string {
s += ''; // convert to string
@ -320,7 +319,7 @@ export function isProbablyBinary(path:string, data?:number[] | Uint8Array) : boo
// check extensions
if (path) {
path = path.toUpperCase();
const BINEXTS = ['.CHR','.BIN','.DAT','.PAL','.NAM','.RLE','.LZ4'];
const BINEXTS = ['.CHR','.BIN','.DAT','.PAL','.NAM','.RLE','.LZ4','.NSF'];
for (var ext of BINEXTS) {
if (path.endsWith(ext)) score++;
}