From 689aa1cf3040f7a0adbe898e111751e1f5d29eee Mon Sep 17 00:00:00 2001 From: "Jason J. Gullickson" Date: Sat, 3 Jan 2015 10:21:35 -0600 Subject: [PATCH] remove extraneous header and tail from filenames in directory listings --- jsfs2.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/jsfs2.js b/jsfs2.js index 0444ee9..7f4f010 100644 --- a/jsfs2.js +++ b/jsfs2.js @@ -197,6 +197,15 @@ http.createServer(function(req, res){ for(var file in stored_files){ if(stored_files.hasOwnProperty(file)){ if(!stored_files[file].private && (file.indexOf(target_url) > -1)){ + + // remove leading path from filename + file = file.slice(target_url.length); + + // remove trailing path from subdirectories + if(file.indexOf("/") > -1){ + file = file.slice(0,(file.indexOf("/") + 1)); + } + public_directory.push(file); } }