@@ -3,8 +3,8 @@ import {findAndReplace} from 'mdast-util-find-and-replace'
3
3
import unicodePunctuation from 'micromark/dist/character/unicode-punctuation.js'
4
4
import unicodeWhitespace from 'micromark/dist/character/unicode-whitespace.js'
5
5
6
- var inConstruct = 'phrasing'
7
- var notInConstruct = [ 'autolink' , 'link' , 'image' , 'label' ]
6
+ const inConstruct = 'phrasing'
7
+ const notInConstruct = [ 'autolink' , 'link' , 'image' , 'label' ]
8
8
9
9
export const gfmAutolinkLiteralFromMarkdown = {
10
10
transforms : [ transformGfmAutolinkLiterals ] ,
@@ -78,10 +78,9 @@ function transformGfmAutolinkLiterals(tree) {
78
78
)
79
79
}
80
80
81
+ // eslint-disable-next-line max-params
81
82
function findUrl ( $0 , protocol , domain , path , match ) {
82
- var prefix = ''
83
- var parts
84
- var result
83
+ let prefix = ''
85
84
86
85
// Not an expected previous character.
87
86
if ( ! previous ( match ) ) {
@@ -99,11 +98,11 @@ function findUrl($0, protocol, domain, path, match) {
99
98
return false
100
99
}
101
100
102
- parts = splitUrl ( domain + path )
101
+ const parts = splitUrl ( domain + path )
103
102
104
103
if ( ! parts [ 0 ] ) return false
105
104
106
- result = {
105
+ let result = {
107
106
type : 'link' ,
108
107
title : null ,
109
108
url : prefix + protocol + parts [ 0 ] ,
@@ -132,7 +131,7 @@ function findEmail($0, atext, label, match) {
132
131
}
133
132
134
133
function isCorrectDomain ( domain ) {
135
- var parts = domain . split ( '.' )
134
+ const parts = domain . split ( '.' )
136
135
137
136
if (
138
137
parts . length < 2 ||
@@ -150,10 +149,10 @@ function isCorrectDomain(domain) {
150
149
}
151
150
152
151
function splitUrl ( url ) {
153
- var trail = / [ ! " & ' ) , . : ; < > ? \] } ] + $ / . exec ( url )
154
- var closingParenIndex
155
- var openingParens
156
- var closingParens
152
+ let trail = / [ ! " & ' ) , . : ; < > ? \] } ] + $ / . exec ( url )
153
+ let closingParenIndex
154
+ let openingParens
155
+ let closingParens
157
156
158
157
if ( trail ) {
159
158
url = url . slice ( 0 , trail . index )
@@ -174,9 +173,11 @@ function splitUrl(url) {
174
173
}
175
174
176
175
function previous ( match , email ) {
177
- var code = match . input . charCodeAt ( match . index - 1 )
176
+ const code = match . input . charCodeAt ( match . index - 1 )
178
177
return (
179
- ( code !== code || unicodeWhitespace ( code ) || unicodePunctuation ( code ) ) &&
178
+ ( match . index === 0 ||
179
+ unicodeWhitespace ( code ) ||
180
+ unicodePunctuation ( code ) ) &&
180
181
( ! email || code !== 47 )
181
182
)
182
183
}
0 commit comments