mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-23 19:06:31 +00:00
fixed target attribute for external links
This commit is contained in:
@@ -87,6 +87,18 @@ describe('resolveLinks', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('External link', function() {
|
||||
var TEST = '<p>This is a <a href="http://www.github.com">external link</a></p>';
|
||||
|
||||
it('should have target="_blank" attribute', function() {
|
||||
var $ = cheerio.load(TEST);
|
||||
|
||||
return resolveLinks('hello.md', resolveFileBasic, $)
|
||||
.then(function() {
|
||||
var link = $('a');
|
||||
expect(link.attr('target')).toBe('_blank');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ function resolveLinks(currentFile, resolveFile, $) {
|
||||
}
|
||||
|
||||
if (LocationUtils.isExternal(href)) {
|
||||
$a.attr('_target', 'blank');
|
||||
$a.attr('target', '_blank');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user