@@ -66,9 +66,10 @@ function linkFixerFactory(sourceUrl) {
6666
6767 // Lowercase all fragment links, since markdown generators do the same
6868 if ( href . includes ( "#" ) ) {
69- const [ urlPath , urlFragment ] = href . split ( "#" ) ;
70-
71- href = `${ urlPath } #${ urlFragment . toLowerCase ( ) } ` ;
69+ const fragmentIndex = href . indexOf ( "#" ) ;
70+ href = `${ href . slice ( 0 , fragmentIndex ) } #${ href
71+ . slice ( fragmentIndex + 1 )
72+ . toLowerCase ( ) } `;
7273 }
7374
7475 if ( oldHref !== href ) {
@@ -79,16 +80,6 @@ function linkFixerFactory(sourceUrl) {
7980 } ;
8081}
8182
82- function getMatches ( string , regex ) {
83- const matches = [ ] ;
84- let match ;
85-
86- while ( ( match = regex . exec ( string ) ) ) {
87- matches . push ( match ) ;
88- }
89- return matches ;
90- }
91-
9283export default function processREADME ( body , options = { } ) {
9384 let processingString = body
9485 // close <img> tags
@@ -141,10 +132,11 @@ export default function processREADME(body, options = {}) {
141132 ) ;
142133
143134 // find the loaders links
144- const loaderMatches = getMatches (
145- processingString ,
146- / h t t p s ? : \/ \/ g i t h u b .c o m \/ ( w e b p a c k | w e b p a c k - c o n t r i b ) \/ ( [ - A - z a - z 0 - 9 ] + - l o a d e r \/ ? ) ( [ ) " ] ) / g,
147- ) ;
135+ const loaderMatches = [
136+ ...processingString . matchAll (
137+ / h t t p s ? : \/ \/ g i t h u b .c o m \/ ( w e b p a c k | w e b p a c k - c o n t r i b ) \/ ( [ - A - z a - z 0 - 9 ] + - l o a d e r \/ ? ) ( [ ) " ] ) / g,
138+ ) ,
139+ ] ;
148140 // dont make relative links for excluded loaders
149141 for ( const match of loaderMatches ) {
150142 if ( ! excludedLoaders . includes ( `${ match [ 1 ] } /${ match [ 2 ] } ` ) ) {
@@ -155,10 +147,11 @@ export default function processREADME(body, options = {}) {
155147 }
156148 }
157149
158- const pluginMatches = getMatches (
159- processingString ,
160- / h t t p s ? : \/ \/ g i t h u b .c o m \/ ( w e b p a c k | w e b p a c k - c o n t r i b ) \/ ( [ - A - z a - z 0 - 9 ] + - p l u g i n \/ ? ) ( [ ) " ] ) / g,
161- ) ;
150+ const pluginMatches = [
151+ ...processingString . matchAll (
152+ / h t t p s ? : \/ \/ g i t h u b .c o m \/ ( w e b p a c k | w e b p a c k - c o n t r i b ) \/ ( [ - A - z a - z 0 - 9 ] + - p l u g i n \/ ? ) ( [ ) " ] ) / g,
153+ ) ,
154+ ] ;
162155 // dont make relative links for excluded loaders
163156 for ( const match of pluginMatches ) {
164157 if ( ! excludedPlugins . includes ( `${ match [ 1 ] } /${ match [ 2 ] } ` ) ) {
0 commit comments