From 6ac8f08e08062163a85f85a3afc3997980a6e625 Mon Sep 17 00:00:00 2001 From: Steven Hugg Date: Tue, 27 Aug 2019 19:27:29 -0400 Subject: [PATCH] fixed isProbablyBinary() on github import --- doc/notes.txt | 2 ++ src/project.ts | 1 - src/services.ts | 2 +- src/util.ts | 3 +-- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/notes.txt b/doc/notes.txt index 09754ddf..1ce0a3d6 100644 --- a/doc/notes.txt +++ b/doc/notes.txt @@ -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 diff --git a/src/project.ts b/src/project.ts index 786494ff..2113f6eb 100644 --- a/src/project.ts +++ b/src/project.ts @@ -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"; diff --git a/src/services.ts b/src/services.ts index 1f9a0e72..9255d614 100644 --- a/src/services.ts +++ b/src/services.ts @@ -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) { diff --git a/src/util.ts b/src/util.ts index 896cac8c..c5157a0e 100644 --- a/src/util.ts +++ b/src/util.ts @@ -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++; }