Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions __tests__/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

exports[`anchor target: should allow _blank if using HTML 1`] = `"<p><a href=\\"https://example.com\\" target=\\"_blank\\" title=\\"\\">test</a></p>"`;

exports[`anchor target: should allow download if using HTML 1`] = `"<p><a download=\\"example.png\\" href=\\"\\" target=\\"_blank\\" title=\\"\\">test</a></p>"`;

exports[`anchor target: should default to _self 1`] = `"<p><a href=\\"https://example.com\\" target=\\"_self\\" title=\\"\\">test</a></p>"`;

exports[`anchors 1`] = `
Expand Down
6 changes: 6 additions & 0 deletions __tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ test('anchor target: should allow _blank if using HTML', () => {
expect(mount(markdown.default('<a href="https://example.com" target="_blank">test</a>')).html()).toMatchSnapshot();
});

test('anchor target: should allow download if using HTML', () => {
expect(
mount(markdown.default('<a download="example.png" href="" target="_blank">test</a>')).html()
).toMatchSnapshot();
});

test('anchors with baseUrl', () => {
const wrapper = mount(
React.createElement(
Expand Down
1 change: 1 addition & 0 deletions components/Anchor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ function Anchor(props) {
Anchor.propTypes = {
baseUrl: PropTypes.string,
children: PropTypes.node.isRequired,
download: PropTypes.string,
href: PropTypes.string,
target: PropTypes.string,
title: PropTypes.string,
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ sanitize.attributes['rdme-embed'] = [
'favicon',
];

sanitize.attributes.a = ['href', 'title', 'class', 'className'];
sanitize.attributes.a = ['href', 'title', 'class', 'className', 'download'];

sanitize.tagNames.push('figure');
sanitize.tagNames.push('figcaption');
Expand Down