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

rollup-plugin-smart-asset

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rollup-plugin-smart-asset - npm Package Compare versions

Comparing version 2.0.5 to 2.0.6

.github/workflows/nodejs.yml

13

dist/rollup-plugin-smart-asset.cjs.js

@@ -210,6 +210,10 @@ 'use strict';

function slash(path) {
function normalizeSlashes(path) {
return path.replace(/\\/g, "/");
}
function addTrailingSlash(path) {
return path.endsWith("/") ? path : path + "/";
}
function markRelative(path) {

@@ -228,3 +232,4 @@ if (path.substr(0, 3) === "../" || path.substr(0, 2) === "./" || path.substr(0, 1) === "/") {

function getAssetPublicPath(assetName, publicPath) {
return slash(publicPath ? path.join(publicPath, assetName) : assetName);
// standard path.join() corrupts protocol prefix "http://"
return publicPath ? addTrailingSlash(publicPath) + assetName : assetName;
}

@@ -237,6 +242,6 @@

const assetRel = path.relative(path.dirname(wrapperFile), assetFile);
return markRelative(slash(path.normalize(assetRel)));
return markRelative(normalizeSlashes(path.normalize(assetRel)));
}
return markRelative(slash(assetsPath ? path.join(assetsPath, assetName) : assetName));
return markRelative(normalizeSlashes(assetsPath ? path.join(assetsPath, assetName) : assetName));
}

@@ -243,0 +248,0 @@

import { promisify } from 'util';
import { readFile, stat, copyFileSync } from 'fs';
import { extname, join, relative, dirname, normalize, parse } from 'path';
import { extname, relative, dirname, join, normalize, parse } from 'path';
import { createFilter } from 'rollup-pluginutils';

@@ -206,6 +206,10 @@ import { sync } from 'mkdirp';

function slash(path) {
function normalizeSlashes(path) {
return path.replace(/\\/g, "/");
}
function addTrailingSlash(path) {
return path.endsWith("/") ? path : path + "/";
}
function markRelative(path) {

@@ -224,3 +228,4 @@ if (path.substr(0, 3) === "../" || path.substr(0, 2) === "./" || path.substr(0, 1) === "/") {

function getAssetPublicPath(assetName, publicPath) {
return slash(publicPath ? join(publicPath, assetName) : assetName);
// standard path.join() corrupts protocol prefix "http://"
return publicPath ? addTrailingSlash(publicPath) + assetName : assetName;
}

@@ -233,6 +238,6 @@

const assetRel = relative(dirname(wrapperFile), assetFile);
return markRelative(slash(normalize(assetRel)));
return markRelative(normalizeSlashes(normalize(assetRel)));
}
return markRelative(slash(assetsPath ? join(assetsPath, assetName) : assetName));
return markRelative(normalizeSlashes(assetsPath ? join(assetsPath, assetName) : assetName));
}

@@ -239,0 +244,0 @@

{
"name": "rollup-plugin-smart-asset",
"version": "2.0.5",
"version": "2.0.6",
"description": "Rollup plugin to rebase, inline or copy assets referenced from the code",

@@ -5,0 +5,0 @@ "keywords": [

@@ -16,6 +16,10 @@ import { promisify } from "util"

// replace windows paths to unix paths on windows platform
function slash(path) {
function normalizeSlashes(path) {
return path.replace(/\\/g, "/")
}
function addTrailingSlash(path) {
return path.endsWith("/") ? path : path + "/"
}
function markRelative(path) {

@@ -33,3 +37,4 @@ if (path.substr(0, 3) === "../" || path.substr(0, 2) === "./" || path.substr(0, 1) === "/") {

function getAssetPublicPath(assetName, publicPath) {
return slash(publicPath ? join(publicPath, assetName) : assetName)
// standard path.join() corrupts protocol prefix "http://"
return publicPath ? addTrailingSlash(publicPath) + assetName : assetName
}

@@ -42,5 +47,5 @@

const assetRel = relative(dirname(wrapperFile), assetFile)
return markRelative(slash(normalize(assetRel)))
return markRelative(normalizeSlashes(normalize(assetRel)))
}
return markRelative(slash(assetsPath ? join(assetsPath, assetName) : assetName))
return markRelative(normalizeSlashes(assetsPath ? join(assetsPath, assetName) : assetName))
}

@@ -47,0 +52,0 @@

@@ -185,2 +185,9 @@ import {

test("load(), copy mode, uses publicPath (with absolute path)", async () => {
const options = { url: "copy", extensions: [".png"], publicPath: "http://cdn.domain.com/assets" }
const result = await smartAsset(options).load("test.png")
expect(result).toEqual(`${idComment}\nexport default "http://cdn.domain.com/assets/test.png"`)
})
test("load(), copy mode, uses useHash", async () => {

@@ -187,0 +194,0 @@ hashFileMock.mockReturnValueOnce("0123456789")

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