@@ -2,13 +2,11 @@ import fs from 'fs'
22import path from 'path'
33
44export class RewriteAssetPathsPlugin {
5- version : string
65 tempDirectory : string
76 localDev : boolean
87 replaceUrl : string
98
10- constructor ( version : string , tempDirectory : string , localDev : boolean , replaceUrl : string ) {
11- this . version = version
9+ constructor ( tempDirectory : string , localDev : boolean , replaceUrl : string ) {
1210 this . tempDirectory = tempDirectory
1311 this . localDev = localDev
1412 this . replaceUrl = replaceUrl
@@ -28,7 +26,7 @@ export class RewriteAssetPathsPlugin {
2826
2927 // Rewrite HTML asset paths. Example:
3028 // ../assets/images/foo/bar.png ->
31- // https://githubdocs.azureedge.net/github-images/enterprise/2.17 /assets/images/foo/bar.png
29+ // https://github.github.com/docs-ghes-3.10 /assets/images/foo/bar.png
3230
3331 if ( resource . isHtml ( ) ) {
3432 // Remove nextjs scripts and manifest.json link
@@ -42,8 +40,8 @@ export class RewriteAssetPathsPlugin {
4240 // Rewrite asset paths
4341 newBody = newBody . replace (
4442 / (?< attribute > s r c | h r e f ) = " (?: \. \. \/ | \/ ) * (?< basepath > _ n e x t \/ s t a t i c | j a v a s c r i p t s | s t y l e s h e e t s | a s s e t s \/ f o n t s | a s s e t s \/ c b - \d + \/ i m a g e s | n o d e _ m o d u l e s ) / g,
45- ( attribute : string , basepath : string ) => {
46- const replaced = `${ this . replaceUrl } /${ this . version } / ${ basepath } `
43+ ( match : string , attribute : string , basepath : string ) => {
44+ const replaced = `${ this . replaceUrl } /${ basepath } `
4745 return `${ attribute } ="${ replaced } `
4846 } ,
4947 )
@@ -52,15 +50,15 @@ export class RewriteAssetPathsPlugin {
5250
5351 // Rewrite CSS asset paths. Example
5452 // url("../assets/fonts/alliance/alliance-no-1-regular.woff") ->
55- // url("https://githubdocs.azureedge.net/github-images/enterprise/2.20 /assets/fonts/alliance/alliance-no-1-regular.woff")
53+ // url("https://github.github.com/docs-ghes-3.10 /assets/fonts/alliance/alliance-no-1-regular.woff")
5654 // url(../../../assets/cb-303/images/octicons/search-24.svg) ->
57- // url(https://githubdocs.azureedge.net/github-images/enterprise/2.20 /assets/cb-303/images/octicons/search-24.svg)
55+ // url(https://github.github.com/docs-ghes-3.10 /assets/cb-303/images/octicons/search-24.svg)
5856 if ( resource . isCss ( ) ) {
5957 if ( ! this . localDev ) {
6058 newBody = newBody . replace (
6159 / (?< attribute > u r l ) (?< paren > \( " | \( ) (?: \. \. \/ ) * (?< basepath > _ n e x t \/ s t a t i c | a s s e t s \/ f o n t s | a s s e t s \/ i m a g e s | a s s e t s \/ c b - \d + \/ i m a g e s ) / g,
62- ( attribute : string , paren : string , basepath : string ) => {
63- const replaced = `${ this . replaceUrl } /${ this . version } / ${ basepath } `
60+ ( match : string , attribute : string , paren : string , basepath : string ) => {
61+ const replaced = `${ this . replaceUrl } /${ basepath } `
6462 return `${ attribute } ${ paren } ${ replaced } `
6563 } ,
6664 )
0 commit comments