Comparing version 0.0.2 to 0.0.3
@@ -23,2 +23,3 @@ /** | ||
//Set to false if you want to see all the underlying calls | ||
//jsftp also has a DEBUG_MODE flag you can set manually to see the raw FTP commands | ||
this.quiet = true; | ||
@@ -97,39 +98,58 @@ | ||
* @param {string} filePath - The path to normalize | ||
* @param {string} [ftpSafe] - Safe for FTP commands | ||
* @return {string} The normalized path | ||
*/ | ||
this.normalize = function(filePath) { | ||
this.normalize = function(filePath, ftpSafe) { | ||
var splitted | ||
, isFile; | ||
, isFile | ||
, ftpSafe = (ftpSafe === true) | ||
//FIXME: Urgh! | ||
, specialCase = false; | ||
if(filePath.length === 0 || filePath === '.' || filePath === './') { | ||
return '.' + path.sep; | ||
specialCase = true; | ||
filePath = '.' + path.sep; | ||
} | ||
if(filePath === '/') { | ||
return filePath; | ||
if(!specialCase && filePath === '/') { | ||
specialCase = true; | ||
} | ||
filePath = path.normalize(filePath); | ||
//Remove trailing slashes and dots | ||
filePath = filePath.replace(/(\/|\.)+$/,''); | ||
//Does it start with a slash or dot? | ||
switch(filePath.charAt(0)) { | ||
case path.sep: | ||
break; | ||
case '.': | ||
default: | ||
if(filePath.charAt(1) !== path.sep) { | ||
filePath = '.' + path.sep + filePath; | ||
} | ||
if(!specialCase) { | ||
filePath = path.normalize(filePath); | ||
//Remove trailing slashes and dots | ||
filePath = filePath.replace(/(\/|\.)+$/,''); | ||
//Does it start with a slash or dot? | ||
switch(filePath.charAt(0)) { | ||
case path.sep: | ||
break; | ||
case '.': | ||
default: | ||
if(filePath.charAt(1) !== path.sep) { | ||
filePath = '.' + path.sep + filePath; | ||
} | ||
} | ||
//Remove trailing slash for anything with a file extension | ||
//Add one for anything without | ||
splitted=filePath.split(path.sep).pop(); | ||
isDir = splitted.indexOf('.') < 0; | ||
if(isDir) { | ||
filePath = filePath + path.sep; | ||
} | ||
} | ||
//Remove trailing slash for anything with a file extension | ||
//Add one for anything without | ||
splitted=filePath.split(path.sep).pop(); | ||
isDir = splitted.indexOf('.') < 0; | ||
if(isDir) { | ||
filePath = filePath + path.sep; | ||
if(ftpSafe) { | ||
//FIXME: pure-ftpd Will refuse to stat stuff beginning with './', so drop it. | ||
if(filePath.indexOf('./') === 0) { | ||
filePath = filePath.substring(2); | ||
} | ||
//Fix for ./ | ||
if(filePath === '') { | ||
filePath = '.'; | ||
} | ||
} | ||
@@ -136,0 +156,0 @@ |
@@ -10,3 +10,3 @@ (function () { | ||
var self = this; | ||
filePath = this.normalize(filePath); | ||
filePath = this.normalize(filePath, true); | ||
@@ -28,3 +28,3 @@ this.debug("MKDIR " + filePath); | ||
var self = this; | ||
filePath = this.normalize(filePath); | ||
filePath = this.normalize(filePath, true); | ||
@@ -50,11 +50,6 @@ this.debug("RMDIR " + filePath); | ||
this.list = function (filePath, cb) { | ||
filePath = this.normalize(filePath); | ||
filePath = this.normalize(filePath, true); | ||
this.debug("LIST " + filePath); | ||
//FIXME: VSFTPD Will refuse to stat './', so use '/'. | ||
if(filePath.length > 1 && filePath.charAt(0) == '.') { | ||
filePath = filePath.substring(1); | ||
} | ||
ftp.ls(filePath, function(err, data) { | ||
@@ -71,3 +66,3 @@ if(err) { | ||
this.put = function (filePath, data, cb) { | ||
filePath = this.normalize(filePath); | ||
filePath = this.normalize(filePath, true); | ||
@@ -124,3 +119,3 @@ this.debug("PUT " + filePath); | ||
filePath = this.normalize(filePath); | ||
filePath = this.normalize(filePath, true); | ||
@@ -127,0 +122,0 @@ this.debug("DELETE " + filePath); |
@@ -9,3 +9,3 @@ { | ||
], | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"repository": { | ||
@@ -12,0 +12,0 @@ "type": "git", |
@@ -89,3 +89,3 @@ #Envoy | ||
##Testing | ||
You need a `tests/secrets.json` file to run integration tests on your own server. See `tests/secrets.example.json` for an example. | ||
You'll need a `tests/secrets.json` file to run the tests with `jake test`. See `tests/secrets.example.json` for an example `secrets.json` file. To test integration with different backends, you can have multiple secret files, name them `secrets.somestring.json` and run the tests with `jake testWith[somestring]`. | ||
@@ -92,0 +92,0 @@ * FTP |
@@ -6,3 +6,3 @@ var assert = require('assert') | ||
, envoy = require('../../lib/envoy') | ||
, secrets = require('../secrets') | ||
, secrets = require(path.join('../',process.env.SECRETS_FILE)) | ||
, fixtures = require('../fixtures') | ||
@@ -9,0 +9,0 @@ , adapters = { |
@@ -6,3 +6,3 @@ var assert = require('assert') | ||
, envoy = require('../../lib/envoy') | ||
, secrets = require('../secrets') | ||
, secrets = require(path.join('../',process.env.SECRETS_FILE)) | ||
, fixtures = require('../fixtures') | ||
@@ -9,0 +9,0 @@ , adapters = { |
@@ -5,3 +5,3 @@ var assert = require('assert') | ||
, envoy = require('../lib/envoy.js') | ||
, secrets = require('./secrets') | ||
, secrets = require(process.env.SECRETS_FILE) | ||
, fixtures = require('./fixtures') | ||
@@ -8,0 +8,0 @@ , adapters = ["memory", "ftp"] |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
82670
1438
17
12