Skip to content

Commit

Permalink
Use base-64 for btoa
Browse files Browse the repository at this point in the history
  • Loading branch information
dkyeremeh committed Jun 18, 2023
1 parent 60a9db4 commit 2b265dc
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"name": "elfinder-node",
"version": "1.0.1",
"version": "1.0.2",
"description": "A NodeJS connector/backend for elFinder file manager",
"main": "src/elfinder.js",
"author": "[email protected]",
"license": "MIT",
"dependencies": {
"adm-zip": "^0.5.10",
"archiver": "^1.2.0",
"base-64": "^1.0.0",
"express": "^4.15.2",
"express-busboy": "^10.1.0",
"fs-extra": "^11.1.1",
"jimp": "^0.2.27",
"lzutf8": "^0.3.5",
"mime-types": "^2.1.12",
"promise": "^8.3.0",
"underscore": "^1.8.3"
Expand Down
10 changes: 4 additions & 6 deletions src/lfs.utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const lz = require('lzutf8'); //Remove after decoupling
const base64 = require('base-64');
const path = require('path'); //Remove
const mime = require('mime-types');
const promise = require('promise');
Expand Down Expand Up @@ -67,7 +67,7 @@ exports.decode = function (dir) {
.replace(/_/g, '/')
.replace(/\./g, '=');

relative = lz.decompress(relative + '==', {
relative = base64.decode(relative + '==', {
inputEncoding: 'Base64',
});
name = path.basename(relative);
Expand All @@ -84,10 +84,8 @@ exports.decode = function (dir) {
//Used by exports.info, api.opne, api.tmb, api.zipdl
exports.encode = function (dir) {
const info = exports.parse(dir);
const relative = lz
.compress(info.path, {
outputEncoding: 'Base64',
})
const relative = base64
.encode(info.path)
.replace(/=+$/g, '')
.replace(/\+/g, '-')
.replace(/\//g, '_')
Expand Down
3 changes: 2 additions & 1 deletion tests/int-tests/api.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const app = require('../app');
const qs = require('qs');
const fs = require('fs-extra');
const { resolve } = require('path');
const base64 = require('base-64');

const request = require('supertest')(app);
const volume = 'v0_Lw';
Expand All @@ -14,7 +15,7 @@ const files = {
zip: resolve(__dirname, '../files/zip.zip'),
};

const encodePath = (path) => 'v0_' + btoa(path);
const encodePath = (path) => 'v0_' + base64.encode(path);

const url = (query = {}) => {
return `/connector?${qs.stringify(query)}`;
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,11 @@ balanced-match@^1.0.0:
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==

base-64@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/base-64/-/base-64-1.0.0.tgz#09d0f2084e32a3fd08c2475b973788eee6ae8f4a"
integrity sha512-kwDPIFCGx0NZHog36dj+tHiwP4QMzsZ3AgMViUBKI0+V5n4U0ufTCUMhnQ04diaRI8EX/QcPfql7zlhZ7j4zgg==

base64-js@^1.3.1:
version "1.5.1"
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a"
Expand Down Expand Up @@ -1774,11 +1779,6 @@ lru-cache@^6.0.0:
dependencies:
yallist "^4.0.0"

lzutf8@^0.3.5:
version "0.3.5"
resolved "https://registry.yarnpkg.com/lzutf8/-/lzutf8-0.3.5.tgz#c4e0237c6b22942ea084909b7f4033d28b25d24d"
integrity sha512-IguWjQkXnfFuE93+IQ5ur/ITwDacfq5gxXL1mZIt+2nvVgVZnl20iUBOSdlRStYh6ptbBnKNffZzCA5KZ3yILQ==

make-dir@^3.0.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-3.1.0.tgz#415e967046b3a7f1d185277d84aa58203726a13f"
Expand Down

0 comments on commit 2b265dc

Please sign in to comment.