Skip to content

Commit

Permalink
fix: issue with invalid characters in downloaded filenames (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianWilkie authored and PatrickHeneise committed May 18, 2019
1 parent e423dbe commit b8b6cd2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const r2 = require('r2')
const fs = require('fs')
const sanitize = require('sanitize-filename')

const MEDIUM_IMG_CDN = 'https://cdn-images-1.medium.com/max/'
let mentionedUsers = []
Expand All @@ -8,7 +9,7 @@ async function downloadImages(images, options = {}) {
const articleImages = []

for (const image of images) {
let file = image.split('/')[image.split('/').length - 1]
let file = sanitize(image.split('/')[image.split('/').length - 1])

if (options.featuredImage && options.featuredImage === file) {
let type = file.split('.')[file.split('.').length - 1]
Expand Down
21 changes: 21 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"commander": "^2.19.0",
"r2": "^2.0.1",
"rss-parser": "^3.6.2",
"underscore.string": "^3.3.5"
"underscore.string": "^3.3.5",
"sanitize-filename": "^1.6.1"
},
"devDependencies": {
"codecov": "^3.1.0",
Expand Down

0 comments on commit b8b6cd2

Please sign in to comment.