Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
uri = path.basename(uri);
}
// Strip empty hash fragments: `#` `#/` `#!/`
if (/^#!?\/?$/.test(hash)) {
hash = '';
}
stream.filename = filename({
crop: options.crop ? '-cropped' : '',
date: easydate('Y-M-d'),
time: easydate('h-m-s'),
size,
width: sizes[0],
height: sizes[1],
url: filenamifyUrl(uri) + filenamify(hash)
});
if (options.incrementalName) {
stream.filename = unusedFilename.sync(stream.filename);
}
return stream;
}
// name
format = format.replace(new RegExp(':name', 'ig'), sanitize(name))
// djradio only
if (typesItem.type === 'djradio') {
const programDate = _.get(song, 'raw.programUi.date')
if (programDate) {
format = format.replace(new RegExp(':programDate'), sanitize(programDate))
}
const programOrder = _.get(song, 'raw.programUi.programOrder')
if (programOrder) {
format = format.replace(
new RegExp(':programOrder'),
sanitize(programOrder)
)
}
}
return format
}
write(dir: string | false, file: string, content: string) {
if (dir === false) {
return;
}
// remove unsafe characters
file = filenamify(file);
if (!this.shouldWrite(file)) {
return;
}
file = path.join(this.config.getRoot(), dir, file);
content = content.trim();
const cacheKey = this.normalize(file);
const cacheValue = checksum(content);
this.newCache.add(cacheKey, cacheValue);
if (!this.doesExist(file)) {
this.stats.added++;
} else if (this.existingCache.didChange(cacheKey, cacheValue)) {
this.stats.updated++;
onSubmit={(e) => {
e.preventDefault();
FileSaver.saveAs(blob, filenamify(`${filename}swatch.sketchpalette`));
setIsPopoverOpen(false);
setColorName(defaultName);
}}
>
function downloadTwitterPhoto(twitter, destinationDir) {
twitter = cleanTwitter(twitter)
const imageName = filenamify(`${twitter}.png`)
const tempDir = temp.mkdirSync()
const imgPath = path.join(tempDir, imageName)
const destinationPath = path.join(destinationDir, imageName)
getProfileImageURL(twitter)
.then(downloadImage)
.catch(logError)
function downloadImage(imgUrl) {
request(imgUrl)
.pipe(fs.createWriteStream(imgPath).on('close', compress))
}
function compress() {
return compressImage(imgPath, destinationPath).then(unlinkImgPath)
}
;['typeText', 'type'].forEach(t => {
const val = sanitize(String(typesItem[t]))
format = format.replace(new RegExp(':' + t, 'ig'), val)
})
const makeArchiveConfig = (config, tweet) => {
let name = filenamify(tweet)
let saveThisOne = `${config.forCol}_${config.account}_${name}_${new Date().getTime()}.warc`
return {
type: 'twitter',
forCol: config.forCol,
uri_r: tweet,
saveTo: path.join(S(settings.get('collections.colWarcs')).template({col: config.forCol}).s, saveThisOne),
header: {
isPartOfV: config.forCol,
description: `Archived by WAIL for ${config.forCol}`
}
}
}
.reduce((sum, element) => {
const sanitized = filenamify(element, { replacement: '_' })
if (sanitized.length > 0) {
sum.push(sanitized)
}
return sum
}, [] as string[])
.join('/')