@@ -3,8 +3,8 @@ import {findAndReplace} from 'mdast-util-find-and-replace'
33import unicodePunctuation from 'micromark/dist/character/unicode-punctuation.js'
44import unicodeWhitespace from 'micromark/dist/character/unicode-whitespace.js'
55
6- var inConstruct = 'phrasing'
7- var notInConstruct = [ 'autolink' , 'link' , 'image' , 'label' ]
6+ const inConstruct = 'phrasing'
7+ const notInConstruct = [ 'autolink' , 'link' , 'image' , 'label' ]
88
99export const gfmAutolinkLiteralFromMarkdown = {
1010 transforms : [ transformGfmAutolinkLiterals ] ,
@@ -78,10 +78,9 @@ function transformGfmAutolinkLiterals(tree) {
7878 )
7979}
8080
81+ // eslint-disable-next-line max-params
8182function findUrl ( $0 , protocol , domain , path , match ) {
82- var prefix = ''
83- var parts
84- var result
83+ let prefix = ''
8584
8685 // Not an expected previous character.
8786 if ( ! previous ( match ) ) {
@@ -99,11 +98,11 @@ function findUrl($0, protocol, domain, path, match) {
9998 return false
10099 }
101100
102- parts = splitUrl ( domain + path )
101+ const parts = splitUrl ( domain + path )
103102
104103 if ( ! parts [ 0 ] ) return false
105104
106- result = {
105+ let result = {
107106 type : 'link' ,
108107 title : null ,
109108 url : prefix + protocol + parts [ 0 ] ,
@@ -132,7 +131,7 @@ function findEmail($0, atext, label, match) {
132131}
133132
134133function isCorrectDomain ( domain ) {
135- var parts = domain . split ( '.' )
134+ const parts = domain . split ( '.' )
136135
137136 if (
138137 parts . length < 2 ||
@@ -150,10 +149,10 @@ function isCorrectDomain(domain) {
150149}
151150
152151function 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
157156
158157 if ( trail ) {
159158 url = url . slice ( 0 , trail . index )
@@ -174,9 +173,11 @@ function splitUrl(url) {
174173}
175174
176175function previous ( match , email ) {
177- var code = match . input . charCodeAt ( match . index - 1 )
176+ const code = match . input . charCodeAt ( match . index - 1 )
178177 return (
179- ( code !== code || unicodeWhitespace ( code ) || unicodePunctuation ( code ) ) &&
178+ ( match . index === 0 ||
179+ unicodeWhitespace ( code ) ||
180+ unicodePunctuation ( code ) ) &&
180181 ( ! email || code !== 47 )
181182 )
182183}
0 commit comments