File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -29,10 +29,19 @@ function optimizeImagesFromPost(markdown: string) {
29
29
/ (?: ! \[ ( .* ?) \] \( h t t p s : \/ \/ i m a g e s .v e l o g .i o \/ ( .* ?) \) ) / g,
30
30
) ;
31
31
if ( ! matches ) return markdown ;
32
- const replacers = matches . map ( ( match ) => [
33
- match ,
34
- match . replace ( 'https://images.velog.io' , 'https://velog.velcdn.com' ) ,
35
- ] ) ;
32
+ console . log ( matches ) ;
33
+ const replacers = matches . map ( ( match ) => {
34
+ const filename =
35
+ match . match ( / h t t p s : \/ \/ i m a g e s .v e l o g .i o \/ ( .* ?) \) / ) ?. [ 1 ] ?? '' ;
36
+ console . log ( filename ) ;
37
+ const proeperlyEncoded = encodeURIComponent ( decodeURI ( filename ) ) ;
38
+ return [
39
+ match ,
40
+ match
41
+ . replace ( 'https://images.velog.io' , 'https://velog.velcdn.com' )
42
+ . replace ( filename , proeperlyEncoded ) ,
43
+ ] ;
44
+ } ) ;
36
45
return replacers . reduce ( ( acc , [ original , optimized ] ) => {
37
46
return acc . replace ( original , optimized ) ;
38
47
} , markdown ) ;
You can’t perform that action at this time.
0 commit comments