From fa597a933925cfd34dfbbc89d0359a3092b4928c Mon Sep 17 00:00:00 2001 From: Lynn Smeria Date: Mon, 10 Sep 2018 11:49:56 +0200 Subject: [PATCH] Zap non-alphanumeric characters in slugs --- package.json | 2 +- src/organise.js | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 717144b..2ced6c2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "publikator", - "version": "0.17.1", + "version": "0.17.2", "main": "index.js", "repository": "https://github.com/aengl/publikator.git", "author": "Lynn Smeria ", diff --git a/src/organise.js b/src/organise.js index 12b04cc..b4a772f 100644 --- a/src/organise.js +++ b/src/organise.js @@ -9,15 +9,16 @@ const tags = require('./tags'); /** * Given a track file, return the album name. */ -const getAlbumName = file => file.common.album.replace(/ /g, '-').toLowerCase(); +const getAlbumName = file => + file.common.album.replace(/[\W_]+/g, '-').toLowerCase(); /** * Given a track file, return the new file name. */ const getFileName = file => - `${file.common.track.no}-${file.common.title}${path.extname(file.path)}` - .replace(/ /g, '-') - .toLowerCase(); + `${file.common.track.no}-${file.common.title + .replace(/[\W_]+/g, '-') + .toLowerCase()}${path.extname(file.path)}`; /** * Strips the extension from a file name;