Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
create(uri: string, size: string, options: Options) {
const sizes = size.split('x');
const stream = screenshotStream(protocolify(uri), size, options);
// Coercing to string here to please Flow
// TODO: Should fix the Flow type so this isn't necessary
const filename = template(`${String(options.filename)}.${String(options.format)}`);
let hash = url.parse(uri).hash || '';
if (path.isAbsolute(uri)) {
uri = path.basename(uri);
}
// Strip empty hash fragments: `#` `#/` `#!/`
if (/^#!?\/?$/.test(hash)) {
hash = '';
}
export function create(uri, size, options) {
const sizes = size.split('x');
const stream = screenshotStream(protocolify(uri), size, options);
const filename = template(`${options.filename}.${options.format}`);
if (path.isAbsolute(uri)) {
uri = path.basename(uri);
}
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)
});