New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@667/ghost-storage-github

Package Overview
Dependencies
Maintainers
0
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@667/ghost-storage-github - npm Package Compare versions

Comparing version 1.1.4 to 1.1.5

48

BaseStorage.js

@@ -19,5 +19,4 @@ const path = require('path')

generateUnique(file, dir, name, ext, i) {
let filename,
append = ''
async generateUnique(file, dir, i) {
let append = ''

@@ -28,33 +27,32 @@ if (i) {

if (ext) {
filename = name + append + ext
file.originalName = file.name
if (file.ext) {
file.name = file.name.replace(file.ext, append + file.ext)
} else {
filename = name + append
file.name = file.name + append
}
return this.exists(file, dir).then((exists) => {
// if the file exists but the sha is not the same then create a new filename otherwise don't
if (exists && typeof exists === 'string') {
throw new Error('File already exists')
} else if (exists) {
i = i + 1
return this.generateUnique(file, dir, name, ext, i)
} else {
return path.posix.join(dir, filename)
}
})
const exists = await this.exists(file, dir)
// if the file exists but the sha is not the same then create a new filename otherwise don't
if (exists && typeof exists === 'string') {
throw new Error('File already exists')
} else if (exists) {
i = i + 1
return await this.generateUnique(file, dir, i)
} else {
return path.posix.join(dir, file.name)
}
}
getUniqueFileName(file, targetDir) {
let ext = path.extname(file.name)
ext = ext === '' ? undefined : ext
const name = this.getSanitizedFileName(path.basename(file.name, ext))
return this.generateUnique(file, targetDir, name, ext, 0)
async getUniqueFileName(file, targetDir) {
const sanitizedName = this.getSanitizedFileName(file.name, file.ext === '' ? undefined : file.ext)
const uniqueName = await this.generateUnique({ ...file, name: sanitizedName }, targetDir, 0)
return uniqueName
}
getSanitizedFileName(fileName) {
getSanitizedFileName(fileName, fileExt) {
const basename = path.basename(fileName, fileExt)
// below only matches ascii characters, @, and .
// unicode filenames like город.zip would therefore resolve to ----.zip
return fileName.replace(/[^\w@.]/gi, '-')
return `${basename.replace(/[^\w@.]/gi, '-')}${fileExt}`
}

@@ -61,0 +59,0 @@ }

@@ -100,2 +100,6 @@ const https = require('https')

if (!/image/.test(mime)) {
// return non image files as-is
return { buffer: buffer.toString('base64') }
}
if (/image/.test(mime) && mime.match(/image\/(.*)/)[1] !== this.imageFormat) {

@@ -102,0 +106,0 @@ const originalExt = file.ext

{
"name": "@667/ghost-storage-github",
"version": "1.1.4",
"version": "1.1.5",
"description": "Save Ghost Blog Content to Github",

@@ -5,0 +5,0 @@ "main": "index.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc