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

image-data-uri

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

image-data-uri - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

6

lib/image-data-uri.js

@@ -24,3 +24,3 @@ 'use strict';

let regExMatches = dataURI.match('data:image/(.*);base64,(.*)');
let regExMatches = dataURI.match('data:(image/.*);base64,(.*)');
return {

@@ -94,3 +94,5 @@ imageType: regExMatches[1],

let imageDecoded = decode(dataURI);
filePath = (!!path.extname(filePath)) ? filePath : filePath + '.' + imageDecoded.imageType;
filePath = (!!path.extname(filePath))
? filePath
: filePath + '.' + mimeTypes.extension(imageDecoded.imageType);
fs.outputFile(filePath, imageDecoded.dataBuffer, err => {

@@ -97,0 +99,0 @@ if (err) {

{
"name": "image-data-uri",
"version": "1.1.0",
"version": "1.1.1",
"description": "Library to easily decode/encode Data URI images",

@@ -5,0 +5,0 @@ "main": "./lib/image-data-uri.js",

@@ -1,4 +0,5 @@

var assert = require("assert");
const fs = require("fs-extra");
const assert = require("assert");
var ImageDataURI = require("../lib/image-data-uri");
const ImageDataURI = require("../lib/image-data-uri");

@@ -41,2 +42,17 @@ const matchMediaType = /^data:([^;,]+)[;,]/;

});
describe("outputFile", () => {
const outputFilePath = `${__dirname}/tmp-output`;
const expectedOutputFile = `${__dirname}/tmp-output.svg`;
it("writes image/svg+xml data to a file with .svg extension", () => {
return ImageDataURI.encodeFromFile("test/test-file.svg")
.then(dataURI => ImageDataURI.outputFile(dataURI, outputFilePath))
.then(outputPath => assert.equal(expectedOutputFile, outputPath));
});
after(function() {
fs.removeSync(expectedOutputFile);
});
});
});
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