Skip to content

Commit

Permalink
BUG Allow external link anchor fiel to work even if the user provides…
Browse files Browse the repository at this point in the history
… a hash mark
  • Loading branch information
Maxime Rainville committed Feb 23, 2021
1 parent a2b721c commit 9a4bf89
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion client/dist/js/TinyMCE_sslink.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 15 additions & 5 deletions client/src/legacy/TinyMCE_sslink.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,24 @@ jQuery.entwine('ss', ($) => {
return Promise.resolve();
},

buildAttributes(data) {
const anchor = data.Anchor && data.Anchor.length ? `#${data.Anchor}` : '';
const href = `${data.Link}${anchor}`;
/**
*
* @param {string|undefined} Anchor
* @param {string} Link
* @param {boolean} TargetBlank
* @param {string} Description
* @returns {{href: string, title: string, target: string}}
*/
buildAttributes({ Anchor, Link, TargetBlank, Description }) {
let anchor = Anchor && Anchor.length ? `#${Anchor}` : '';
// Make sure, there's no more than one # character at the start of the anchor
anchor = anchor.replace(/^#+/, '#');
const href = `${Link}${anchor}`;

return {
href,
target: data.TargetBlank ? '_blank' : '',
title: data.Description,
target: TargetBlank ? '_blank' : '',
title: Description,
};
},

Expand Down

0 comments on commit 9a4bf89

Please sign in to comment.