@salesforcedevs/sfdocs-image-transformer
Advanced tools
Comparing version 1.0.4 to 1.0.5-alpha
@@ -17,3 +17,3 @@ "use strict"; | ||
function updateImagePath(node, vfile, baseURLConfig) { | ||
const imagePath = node.url; | ||
let imagePath = node.url; | ||
// Check for for non-internal paths | ||
@@ -37,2 +37,8 @@ if (!isInternalPath(imagePath)) { | ||
const contentRepoPath = filePath.substring(0, matchContentLocalePath.index).trim(); | ||
// Fix for Included files using images from media folder | ||
// When an included file has images, then the path contains full absolute path of the image. | ||
// The full path is trimmed till media folder for the existing logic to work. | ||
if (imagePath.includes('/media')) { | ||
imagePath = imagePath.substring(imagePath.indexOf('/media')); | ||
} | ||
// Split the repositoryPath by using "/" delimiter and get the last word for repo id | ||
@@ -39,0 +45,0 @@ // Ex: contentRepoPath = /Users/sfdev/doc-framework-monorepo/packages/example-repository |
{ | ||
"version": "1.0.4", | ||
"version": "1.0.5-alpha", | ||
"name": "@salesforcedevs/sfdocs-image-transformer", | ||
@@ -4,0 +4,0 @@ "description": "Salesforce Docs markdown plugin for image transormation", |
@@ -72,2 +72,9 @@ import { updateImagePath, BaseURLConfig } from '../image-cdn-mapper'; | ||
}); | ||
it('should construct CDN URL for a sub-folder inside images coming from included shared file', () => { | ||
mockNode.url = '/usr/test/dist/repos/media/images/overview/overview.png'; | ||
mockVFile.path = '/example-repository/content/ja-jp/subfolder/file.md'; | ||
updateImagePath(mockNode, mockVFile, mockBaseURLConfig); | ||
expect(mockNode.url).toBe('https://cdn.example.com/example-repository/media/images/overview/overview.png'); | ||
}); | ||
}); |
@@ -25,3 +25,3 @@ import { VFile } from 'vfile'; | ||
export function updateImagePath(node: any, vfile: VFile, baseURLConfig: BaseURLConfig): void { | ||
const imagePath = node.url; | ||
let imagePath = node.url; | ||
@@ -50,3 +50,8 @@ // Check for for non-internal paths | ||
const contentRepoPath = filePath.substring(0, matchContentLocalePath.index).trim(); | ||
// Fix for Included files using images from media folder | ||
// When an included file has images, then the path contains full absolute path of the image. | ||
// The full path is trimmed till media folder for the existing logic to work. | ||
if (imagePath.includes('/media')) { | ||
imagePath = imagePath.substring(imagePath.indexOf('/media')); | ||
} | ||
// Split the repositoryPath by using "/" delimiter and get the last word for repo id | ||
@@ -53,0 +58,0 @@ // Ex: contentRepoPath = /Users/sfdev/doc-framework-monorepo/packages/example-repository |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
65057
529
2