@salesforcedevs/sfdocs-no-relative-link
Advanced tools
Comparing version 0.0.1-alphav2 to 0.0.1-alphav3
@@ -32,3 +32,3 @@ "use strict"; | ||
if (isInternalPath(node.url) && denyInternalLinkInFile) { | ||
const errorMessage = new vfile_message_1.default(`Using relative links is not allowed in ${folder} files. Please use absolute links instead of ${node.url}.`, node, "relative-link-not-allowed"); | ||
const errorMessage = new vfile_message_1.default(`Using relative links is not allowed in ${folder.replace('/', '')} files. Please use absolute links (/docs/..) instead of ${node.url}.`, node, "relative-link-not-allowed"); | ||
errorMessage.fatal = true; | ||
@@ -35,0 +35,0 @@ file.messages.push(errorMessage); |
{ | ||
"name": "@salesforcedevs/sfdocs-no-relative-link", | ||
"version": "0.0.1-alphav2", | ||
"version": "0.0.1-alphav3", | ||
"description": "Validate the relative links in any folder and throw error/warning after check", | ||
@@ -5,0 +5,0 @@ "author": "SFDocs Team", |
@@ -65,3 +65,3 @@ import dedent from 'dedent'; | ||
expect(result.messages[0].fatal).toBeTruthy(); | ||
expect(result.messages[0].toString()).toBe('2:1-2:32: Using relative links is not allowed in shared files. Please use absolute links instead of ./testing.md.'); | ||
expect(result.messages[0].toString()).toBe('2:1-2:32: Using relative links is not allowed in shared files. Please use absolute links (/docs/..) instead of ./testing.md.'); | ||
}); | ||
@@ -89,6 +89,30 @@ | ||
expect(result.messages[0].fatal).toBeTruthy(); | ||
expect(result.messages[0].toString()).toBe('2:1-2:40: Using relative links is not allowed in shared files. Please use absolute links instead of ../guides/testing.md.'); | ||
expect(result.messages[0].toString()).toBe('2:1-2:40: Using relative links is not allowed in shared files. Please use absolute links (/docs/..) instead of ../guides/testing.md.'); | ||
}); | ||
test('should throw error for internal link within shared folder - nested folder usecase', () => { | ||
mockFs({ | ||
'/test/content/shared': { | ||
'example.md': 'dummy test', | ||
'testing.md': 'dummy test' | ||
}, | ||
'/test/content/shared/level1': { | ||
'levelTesting.md': 'dummy test', | ||
}, | ||
}); | ||
const md = dedent(` | ||
# Test heading | ||
[Link to Level Testing](./level1/levelTesting.md) | ||
`); | ||
const file = vfile({ path: '/test/content/shared/example.md', contents: md }); | ||
const result = processMarkdown(file, ['error', 'shared']); | ||
expect(result.messages.length).toEqual(1); | ||
expect(result.messages[0].fatal).toBeTruthy(); | ||
expect(result.messages[0].toString()).toBe('2:1-2:50: Using relative links is not allowed in shared files. Please use absolute links (/docs/..) instead of ./level1/levelTesting.md.'); | ||
}); | ||
}); |
@@ -34,3 +34,3 @@ /** | ||
if (isInternalPath(node.url) && denyInternalLinkInFile) { | ||
const errorMessage: VFileMessage = new VMessage(`Using relative links is not allowed in ${folder} files. Please use absolute links instead of ${node.url}.`, node, "relative-link-not-allowed"); | ||
const errorMessage: VFileMessage = new VMessage(`Using relative links is not allowed in ${folder.replace('/','')} files. Please use absolute links (/docs/..) instead of ${node.url}.`, node, "relative-link-not-allowed"); | ||
errorMessage.fatal = true; | ||
@@ -37,0 +37,0 @@ file.messages.push(errorMessage); |
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
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
80381
748