@hashicorp/react-image
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -78,12 +78,13 @@ 'use strict'; | ||
// scrape format from file extension if not provided | ||
if (!format) format = url.match(/\.(\w+)$/)[1]; // set default imgix options, merge user preferences with priority | ||
var parsedFormat = parseFormat(format, url); | ||
var formatOption = parsedFormat ? { | ||
fm: parsedFormat | ||
} : {}; // set default imgix options, merge user preferences with priority | ||
var opts = assign({ | ||
fm: format, | ||
fit: aspectRatio ? 'crop' : 'max', | ||
q: 80 | ||
}, imgixOptions); // if it's an SVG, we don't need the picture element, so return | ||
}, formatOption, imgixOptions); // if it's an SVG, we don't need the picture element, so return | ||
if (format === 'svg') return React.createElement("img", _extends({ | ||
if (parsedFormat === 'svg') return React.createElement("img", _extends({ | ||
"data-testid": "image-root", | ||
@@ -119,2 +120,11 @@ src: url, | ||
function parseFormat(format, url) { | ||
// Use the format prop if it was provided | ||
if (format) return format; // Fallback to parsing it from the extension | ||
var extensionMatch = url.match(/\.(\w+)$/); | ||
var hasExtension = !!extensionMatch && !!extensionMatch[1]; | ||
return hasExtension ? extensionMatch[1] : false; | ||
} | ||
function formatSteps(steps, opts, aspectRatio, src) { | ||
@@ -121,0 +131,0 @@ return steps.map(function (s) { |
{ | ||
"name": "@hashicorp/react-image", | ||
"description": "super optimized image element, pulls from dato and formats for 7 screen sizes in two formats. Skips optimization for SVGs.", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"author": "Hashicorp - Jeff Escalante", | ||
@@ -21,3 +21,3 @@ "dependencies": { | ||
}, | ||
"gitHead": "2820c17206084ce62de83b43a65d4f407418e519" | ||
"gitHead": "661e01731e31241b9b32862dad4eb376cabefe2a" | ||
} |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
23163
114
1