Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@stendahls/libravatar-server

Package Overview
Dependencies
Maintainers
5
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stendahls/libravatar-server - npm Package Compare versions

Comparing version 1.6.0 to 1.7.0

modules/silhouetteImage/index.js

3

package.json
{
"name": "@stendahls/libravatar-server",
"version": "1.6.0",
"version": "1.7.0",
"description": "A node implementation of the Libravatar API",

@@ -18,2 +18,3 @@ "main": "server.js",

"got": "^9.6.0",
"is-url": "^1.2.4",
"sharp": "^0.23.0"

@@ -20,0 +21,0 @@ },

#!/usr/bin/env node
require( 'dotenv' ).config();
const path = require( 'path' );
const express = require( 'express' );
const sharp = require( 'sharp' );
const providers = require( './providers/' );
const silhouetteImage = require('./modules/silhouetteImage');
const isUrl = require('is-url');

@@ -152,3 +152,2 @@ const app = express();

let defaultFallback = false;
let defaultKey = `${ targetSize }x${ targetSize }`;

@@ -164,11 +163,16 @@ if ( request.query.d ) {

if ( defaultFallback ) {
console.log(defaultFallback);
if ( defaultFallback === '404' ) {
response.sendStatus( 404 );
return true;
}
// Special values for default fallback
// https://wiki.libravatar.org/api/
// Each case can either set `avatarImage` to
// set the avatar image to return
// or return true to stop checking
if (defaultFallback === '404') {
response.sendStatus( 404 );
return true;
}
if (defaultFallback === 'mm') {
avatarImage = await silhouetteImage.get(targetSize);
}
// If `defaultFallback` is a url, redirect to it
if ( isUrl(defaultFallback) ) {
response.redirect( 302, defaultFallback );

@@ -179,10 +183,6 @@

if ( defaultImageCache[ defaultKey ] ) {
avatarImage = defaultImageCache[ defaultKey ];
} else {
avatarImage = await sharp( path.join( __dirname, 'assets', 'default.jpg' ) )
.resize( targetSize, targetSize )
.toBuffer();
defaultImageCache[ defaultKey ] = avatarImage;
// After checking all default fallbacks, fallback
// to getting a silhouetteImage instead
if (!avatarImage) {
avatarImage = await silhouetteImage.get(targetSize);
}

@@ -189,0 +189,0 @@ }

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