node-archiver icon indicating copy to clipboard operation
node-archiver copied to clipboard

directory to archive with name includes slash '/'

Open tymiao1220 opened this issue 7 years ago • 5 comments

Hi Developer,

I am wondering is there a way to directory an archive to a name with '/',

var NameWithSlash = 'Folder 1/2'; archive.directory( '/path/to/be/archived', '/des/path/'+NameWithSlash, { date: new Date() });

When I did that now it will automatically recognize '/' in NameWithSlash as a path separator instead of string.

What is the right way to doing so?

Thanks,

tymiao1220 avatar May 27 '18 21:05 tymiao1220

I'm not sure I've ever tried using / as part of a filename as I believe there are OS that don't support that like Windows.

Have you confirmed this works in zip or tar outside of archiver? I know theres a few spots in archiver that uses slash detect directory so that would be a hard limit to such with archiver without refactoring of codebase.

ctalkington avatar Jun 21 '18 23:06 ctalkington

Same issue on linux trying to archive a directory whose files names contains backslashes (which are legit on *nix)

AQAMAD avatar Jun 29 '18 12:06 AQAMAD

Same problem here with macOS

soufianerafik avatar Aug 31 '18 16:08 soufianerafik

we can replace "/" or "" with ":" Node archiver replace ":" as "/" in string name

Regex for replaceing slashes: fileName.replace(/\|//gm, ':')

Hope this will help

sonirakesh15 avatar Jul 29 '22 02:07 sonirakesh15

Node archiver replace ":" as "/" in string name

any idea on how to tweak that? having issues with a folder containing : that's being replaced and apparently some Windows users can't extract the archive

zoellner avatar Feb 01 '23 10:02 zoellner