
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Tiny JSX helper function for high-DPI (Retina Display) images.
394 bytes minified and gzipped for ESM (830 bytes for ES5).
npm install --save img-srcx
# or
yarn install img-srcx
# or
pnpm install img-srcx
If you’re using this in older runtimes, such as node 8, Internet Explorer, or Android before 4.4.4, you’ll need to use a URL
polyfill. You may find Can I use URL
? useful.
import { srcx, type Scale } from "img-srcx";
function MyImageComponent({ src, forceScale }: { src: string; forceScale?: Scale; }) {
return <img {...srcx(src, { forceScale })} />;
}
function Root() {
return (
<div>
<MyImageComponent src="https://repo.chariz.com/CydiaIcon.png" />
<MyImageComponent src="https://www.google.com/google.jpg" forceScale={1} />
<MyImageComponent src="https://github.githubassets.com/favicons/favicon.svg" />
</div>
);
}
ReactDOM.render(
<Root />,
document.getElementById("root")
);
Yields the following rendered HTML:
<div>
<img
src="https://repo.chariz.com/CydiaIcon.png"
srcSet="https://repo.chariz.com/CydiaIcon@2x.png 2x,https://repo.chariz.com/CydiaIcon@3x.png 3x">
<img
src="https://www.google.com/google.jpg">
<img
src="https://github.githubassets.com/favicons/favicon.svg">
</div>
srcx(src: string, options?: { scales?: Scale[], forceScale?: Scale }): { src: string; srcSet?: string }
Returns JSX properties for use on an <img>
element. The src
and srcSet
attributes set as appropriate for the given parameters.
src
attribute, unless forceScale
is set.[1, 2, 3]
. The lowest scale will be used as the src
attribute, and the remainder will be used as the srcSet
attribute, unless forceScale
is set.src
attribute will be set to the URL matching the given scale, and the srcSet
attribute will be set to the remaining scales above the given scale.Paths ending in .svg
will be returned as-is, without srcSet
.
Scale
A type for indicating scale factors. This is defined to 1 | 2 | 3
, matching the common scale factors for high-DPI images.
Developed by Chariz:
Licensed under the Apache License, version 2.0. Refer to LICENSE.md.
FAQs
Tiny JSX helper function for high-DPI (Retina Display) images.
We found that img-srcx demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.