diff --git a/package.json b/package.json index 263c3cb..8b7f6e0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wetty", - "version": "1.3.0", + "version": "1.3.1", "description": "WeTTY = Web + TTY. Terminal access in browser over http/https", "homepage": "https://github.com/butlerx/wetty", "repository": { diff --git a/src/client/index.ts b/src/client/index.ts index 454f038..432fd7a 100644 --- a/src/client/index.ts +++ b/src/client/index.ts @@ -99,6 +99,12 @@ socket.on('connect', () => { mimeType = typeData.mime; fileExt = typeData.ext; } + // Check if the buffer is ASCII + // Ref: https://stackoverflow.com/a/14313213 + else if (/^[\x00-\x7F]*$/.test(fileCharacters)) { // eslint-disable-line no-control-regex + mimeType = 'text/plain'; + fileExt = 'txt'; + } const fileName = `file-${new Date() .toISOString() .split('.')[0]