diff --git a/__tests__/ExpensiMark-HTML-test.js b/__tests__/ExpensiMark-HTML-test.js index a6b3f4ff..dd4937df 100644 --- a/__tests__/ExpensiMark-HTML-test.js +++ b/__tests__/ExpensiMark-HTML-test.js @@ -1366,3 +1366,11 @@ test('Test strikethrough with multiple tilde characters', () => { testString = '~~~~'; expect(parser.replace(testString)).toBe('~~~~'); }); + +test('Test strikethrough with link with URL that contains tilde', () => { + let testString = '~[Example Link](https://example.com/?example=~ex)~'; + expect(parser.replace(testString)).toBe('Example Link'); + + testString = '~[Example Link](https://example.com/?~example=~~~ex~)~'; + expect(parser.replace(testString)).toBe('Example Link'); +}); diff --git a/lib/ExpensiMark.js b/lib/ExpensiMark.js index 70c63dd2..fdb2eaf5 100644 --- a/lib/ExpensiMark.js +++ b/lib/ExpensiMark.js @@ -210,7 +210,7 @@ export default class ExpensiMark { }, { name: 'strikethrough', - regex: /\B~((?=\S)(([^\s~]|\s(?!~))+?))~\B(?![^<]*(<\/pre>|<\/code>|<\/a>))/g, + regex: /\B~((?![\s~])[\s\S]*?[^\s~])~\B(?![^<]*(<\/pre>|<\/code>|<\/a>))/g, replacement: (match, g1) => (this.containsNonPairTag(g1) ? match : `${g1}`), }, {