Skip to content

Commit 8c99c85

Browse files
committed
feat: add default public path
1 parent 3e4143b commit 8c99c85

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

test/links.test.ts

+14-10
Original file line numberDiff line numberDiff line change
@@ -191,39 +191,43 @@ describe('Links', () => {
191191
const inputPath = resolve(__dirname, './mocks/external-link.md');
192192
const input = readFileSync(inputPath, 'utf8');
193193

194-
let result = '';
194+
let link = '';
195195

196-
transformYfm(input, inputPath, {
196+
const html = transformYfm(input, inputPath, {
197197
transformLink: (href: string) => {
198-
href = href.replace('.md', '');
199-
result = href;
198+
link = href;
200199
return href;
201200
},
202201
});
203202

204-
expect(result).toEqual('external-link');
203+
expect(link).not.toEqual('https://test.com/');
204+
expect(html).toEqual(
205+
'<p><a href="https://test.com/" target="_blank" rel="noreferrer noopener">Absolute link</a></p>\n',
206+
);
205207
});
206208

207209
test('Should not call the "transformLink" callback for external link with default path', () => {
208210
const inputPath = resolve(__dirname, './mocks/external-link.md');
209211
const input = readFileSync(inputPath, 'utf8');
210212

211-
let result = '';
213+
let link = '';
212214

213-
transformYfm(
215+
const html = transformYfm(
214216
input,
215217
'mocks/external-link.md',
216218
{
217219
transformLink: (href: string) => {
218-
href = href.replace('.md', '');
219-
result = href;
220+
link = href;
220221
return href;
221222
},
222223
},
223224
true,
224225
);
225226

226-
expect(result).toEqual('mocks/external-link');
227+
expect(link).not.toEqual('https://test.com/');
228+
expect(html).toEqual(
229+
'<p><a href="https://test.com/" target="_blank" rel="noreferrer noopener">Absolute link</a></p>\n',
230+
);
227231
});
228232
});
229233
});

0 commit comments

Comments
 (0)