Skip to content

Commit

Permalink
fix: opens external anchor using rel=noopener (#2728)
Browse files Browse the repository at this point in the history
* fix: opens external anchor using rel=noopener

see https://developers.google.com/web/tools/lighthouse/audits/noopener

* fix: use external noopener as rel
  • Loading branch information
JLHwung authored and NoahDragon committed Aug 29, 2017
1 parent 8162fd8 commit dfb5a4b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/plugins/helper/link_to.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function linkToHelper(path, text, options) {

if (attrs.external) {
attrs.target = '_blank';
attrs.rel = 'external';
attrs.rel = 'external noopener';
attrs.external = null;
}

Expand Down
4 changes: 2 additions & 2 deletions test/scripts/helpers/link_to.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ describe('link_to', () => {

it('external (boolean)', () => {
linkTo('http://hexo.io/', 'Hexo', true)
.should.eql('<a href="http://hexo.io/" title="Hexo" target="_blank" rel="external">Hexo</a>');
.should.eql('<a href="http://hexo.io/" title="Hexo" target="_blank" rel="external noopener">Hexo</a>');
});

it('external (object)', () => {
linkTo('http://hexo.io/', 'Hexo', {external: true})
.should.eql('<a href="http://hexo.io/" title="Hexo" target="_blank" rel="external">Hexo</a>');
.should.eql('<a href="http://hexo.io/" title="Hexo" target="_blank" rel="external noopener">Hexo</a>');
});

it('class (string)', () => {
Expand Down

0 comments on commit dfb5a4b

Please sign in to comment.