You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@salesforcedevs/sfdocs-image-transformer

Package Overview
Dependencies
Maintainers
0
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@salesforcedevs/sfdocs-image-transformer - npm Package Compare versions

Comparing version

to
1.0.5-fix-alpha2

9

dist/index.js

@@ -14,5 +14,10 @@ "use strict";

const imageResizeClassSet = new Set(["image-xxl", "image-full", "image-xl", "image-lg", "image-md", "image-sm", "image-xs", "image-xxs", "image-icon-lg", "image-icon-md", "image-icon-sm", "image-framed", "image-framed-light"]);
const MEDIA_FOLDER = '/media';
/**
* Function to check if the image path is already transformed,
* if path is transformed we will not transform them again.
* The transformation of image path happens as part of shared-file-image-link-transformer-plugin
* https://github.com/salesforcedevs/doc-framework-monorepo/blob/develop/packages/%40salesforcedocs/generic-directive-plugin/src/remark-plugins/shared-file-links/shared-file-image-link-transformer-plugin.ts
* Image path transformation happens for only images as part of shared file.
* Hence for all the other image path we need to append ./
* @param imagePath

@@ -22,3 +27,3 @@ * @returns true/false

function isTransformedPath(imagePath) {
return imagePath && path_1.default.isAbsolute(imagePath) && !imagePath.startsWith('/media');
return imagePath && path_1.default.isAbsolute(imagePath) && !imagePath.startsWith(MEDIA_FOLDER);
}

@@ -35,3 +40,3 @@ /**

const imagePath = node.url;
if ((0, image_cdn_mapper_1.isInternalPath)(imagePath) && !imagePath.startsWith('./') && !isTransformedPath(imagePath)) {
if (!isTransformedPath(imagePath) && (0, image_cdn_mapper_1.isInternalPath)(imagePath) && !imagePath.startsWith('./')) {
const prefix = path_1.default.isAbsolute(imagePath) ? '.' : './';

@@ -38,0 +43,0 @@ node.url = prefix + imagePath;

{
"version": "1.0.5-fix-alpha1",
"version": "1.0.5-fix-alpha2",
"name": "@salesforcedevs/sfdocs-image-transformer",

@@ -4,0 +4,0 @@ "description": "Salesforce Docs markdown plugin for image transormation",

@@ -18,5 +18,11 @@ import { Transformer } from 'unified';

const MEDIA_FOLDER = '/media';
/**
* Function to check if the image path is already transformed,
* if path is transformed we will not transform them again.
* The transformation of image path happens as part of shared-file-image-link-transformer-plugin
* https://github.com/salesforcedevs/doc-framework-monorepo/blob/develop/packages/%40salesforcedocs/generic-directive-plugin/src/remark-plugins/shared-file-links/shared-file-image-link-transformer-plugin.ts
* Image path transformation happens for only images as part of shared file.
* Hence for all the other image path we need to append ./
* @param imagePath

@@ -26,3 +32,3 @@ * @returns true/false

function isTransformedPath(imagePath: string): boolean {
return imagePath && path.isAbsolute(imagePath) && !imagePath.startsWith('/media');
return imagePath && path.isAbsolute(imagePath) && !imagePath.startsWith(MEDIA_FOLDER);
}

@@ -40,3 +46,3 @@

const imagePath = node.url;
if (isInternalPath(imagePath) && !imagePath.startsWith('./') && !isTransformedPath(imagePath)) {
if (!isTransformedPath(imagePath) && isInternalPath(imagePath) && !imagePath.startsWith('./')) {
const prefix = path.isAbsolute(imagePath) ? '.' : './';

@@ -43,0 +49,0 @@ node.url = prefix + imagePath;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet