@@ -43,6 +43,14 @@ describe('paste-markdown', function () {
4343 assert . equal ( textarea . value , 'The examples can be found [here](https://github.com).' )
4444 } )
4545
46+ it ( 'creates a markdown link when the pasted url includes a trailing slash' , function ( ) {
47+ // eslint-disable-next-line i18n-text/no-en
48+ textarea . value = 'The examples can be found here.'
49+ textarea . setSelectionRange ( 26 , 30 )
50+ paste ( textarea , { 'text/plain' : 'https://www.github.com/' } )
51+ assert . equal ( textarea . value , 'The examples can be found [here](https://www.github.com/).' )
52+ } )
53+
4654 it ( "doesn't paste a markdown URL when pasting over a selected URL" , function ( ) {
4755 // eslint-disable-next-line i18n-text/no-en
4856 textarea . value = 'The examples can be found here: https://docs.github.com'
@@ -66,6 +74,15 @@ describe('paste-markdown', function () {
6674 assert . equal ( textarea . value , '@' )
6775 } )
6876
77+ it ( "doesn't paste markdown URL when additional text is being copied" , function ( ) {
78+ textarea . value = 'github'
79+ textarea . setSelectionRange ( 0 , 6 )
80+ paste ( textarea , { 'text/plain' : 'https://github.com plus some other content' } )
81+ // Synthetic paste events don't manipulate the DOM. The same textarea value
82+ // means that the event handler didn't fire and normal paste happened.
83+ assert . equal ( textarea . value , 'github' )
84+ } )
85+
6986 it ( 'turns html tables into markdown' , function ( ) {
7087 const data = {
7188 'text/html' : tableHtml
0 commit comments