Closed thom4parisot closed 6 years ago
I have inspected the problem a bit further.
It seems that {dir}
is URL encoded by url-template
, maybe because /
is considered as an operator (don't know what it means):
const urlTemplate = require('url-template')
const template = urlTemplate.parse('{dir}/{name}.sq{ext}')
template.expand({ dir: 'test', name: 'a', ext: '.jpg' })
// outputs "test/a.sq.jpg"
template.expand({ dir: 'test/test', name: 'a', ext: '.jpg' })
// outputs "test%2F/a.sq.jpg"
The problem lives here:
If {dir}
leads, or if output
equals /mnt/otherdrive/{file}{ext}
, output will be absolute-ised prior to its expansion.
Maybe it should be absolute-ised later, if not already absolute (cf. path.isAbsolute
) like here, to benefit from url-template:
Maybe some additional modifiers like {cwd}
and {relative_path}
(between file and cwd
) would help tuning the dest path too.
What do you think?
Thank you for looking into this - I think I'll have to rethink using url-template
, as the slashes will always be encoded. I see your PR solves this, but ideally I'd like to avoid using decodeURIComponent
.
@oncletom The format you are looking for (in your opening post) is {+dir}/{name}.sq{ext}
. The plus symbol indicates no characters will be encoded, per RFC 6570.
Oh bummer! Thanks for the heads upb and for the finding; I totally missed it from the syntax!
Than you so much :-)
Hello!
Thanks for this tool, it works beautifully and is probably the best in town :-)
I discovered
url-template
but the{dir}
directive does not correspond to what I expected. Ref torequire('path').parse
.For example, this is a command I used and did not work as expected:
I was expecting
{dir}
to be equal to eithercontent/playstation/images
or/Users/oncletom/workspace/emunova/emunova.net/content/playstation/images
.{dir}
looks like an encoded value of some sort, which is prefixed by$(pwd)
.Am I using it wrong?
Thanks for your help :-)