permalinks icon indicating copy to clipboard operation
permalinks copied to clipboard

Permalinks should never try to create a folder outside(above) of Metalsmith(__dirname)

Open nikmartin opened this issue 10 years ago • 1 comments

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.

nikmartin avatar Oct 25 '15 16:10 nikmartin

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);
  }

IanMercer avatar May 10 '16 19:05 IanMercer

Solved in v3.0.0: https://github.com/metalsmith/permalinks/blob/v3.0.0/src/index.js#L211

webketje avatar Dec 13 '23 20:12 webketje