permalinks
permalinks copied to clipboard
Permalinks should never try to create a folder outside(above) of Metalsmith(__dirname)
Related to #25:
.use(permalinks({
relative: false,
pattern: ':collection/:title'
}))
will try to create about.md, which is NOT in a collection, as /about/index.html, which is the root of the drive on a LInux or OS X system. changing it to:
.use(permalinks({
relative: false,
pattern: './:collection/:title'
}))
makes it relative to something, which happens to be the root of the build dir. What should probably happen is permalinks should always build paths relative to the build dir.
It would be preferable if the plugin code actually prevented the accidental use of a / at the start of a pattern. After getting the path maybe something like:
// Remove leading / to avoid escaping to the root folder!!
if (path.indexOf('/') === 0){
path = path.substring(1);
}
Solved in v3.0.0: https://github.com/metalsmith/permalinks/blob/v3.0.0/src/index.js#L211