File tree 5 files changed +103
-11
lines changed
5 files changed +103
-11
lines changed Original file line number Diff line number Diff line change 26
26
"react-icons" : " 4.12.0" ,
27
27
"react-markdown" : " 9.0.1" ,
28
28
"rehype-raw" : " 7.0.0" ,
29
- "remark-gfm" : " 4.0.0"
29
+ "remark-gfm" : " 4.0.0" ,
30
+ "sanitize-html" : " 2.13.1"
30
31
},
31
32
"devDependencies" : {
32
33
"@types/lodash" : " 4.17.13" ,
33
34
"@types/node" : " 20.17.6" ,
34
35
"@types/react" : " 18.3.12" ,
35
36
"@types/react-dom" : " 18.3.1" ,
37
+ "@types/sanitize-html" : " 2.13.0" ,
36
38
"eslint" : " 8.57.1" ,
37
39
"eslint-config-next" : " 14.2.16" ,
38
40
"prettier" : " 3.3.3" ,
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ import { MdMenu } from "react-icons/md";
38
38
import ReactMarkdown from "react-markdown" ;
39
39
import rehypeRaw from "rehype-raw" ;
40
40
import remarkGfm from "remark-gfm" ;
41
+ import sanitizeHtml from "sanitize-html" ;
41
42
42
43
type FilePath = string ;
43
44
type UrlPath = string ;
@@ -194,10 +195,6 @@ const getNavigation = (manifest: Manifest): Nav => {
194
195
return navigation ;
195
196
} ;
196
197
197
- const removeHtmlComments = ( string : string ) => {
198
- return string . replace ( / < ! - - [ \s \S ] * ?- - > / g, "" ) ;
199
- } ;
200
-
201
198
export const getStaticPaths : GetStaticPaths = ( ) => {
202
199
const manifest = getManifest ( ) ;
203
200
const routes = mapRoutes ( manifest ) ;
@@ -221,7 +218,7 @@ export const getStaticProps: GetStaticProps = (context) => {
221
218
const route = routes [ urlPath ] ;
222
219
const { body } = fm ( readContentFile ( route . path ) ) ;
223
220
// Serialize MDX to support custom components
224
- const content = removeHtmlComments ( body ) ;
221
+ const content = sanitizeHtml ( body ) ;
225
222
const navigation = getNavigation ( manifest ) ;
226
223
const version = manifest . versions [ 0 ] ;
227
224
Original file line number Diff line number Diff line change @@ -29,7 +29,12 @@ export const createAppLinkHref = (
29
29
}
30
30
31
31
if ( appsHost && app . subdomain && app . subdomain_name ) {
32
- href = `${ protocol } //${ appsHost } /` . replace ( "*" , app . subdomain_name ) ;
32
+ const baseUrl = `${ protocol } //${ appsHost } ` ;
33
+ const url = new URL ( baseUrl ) ;
34
+ url . hostname = appsHost . replace ( "*" , app . subdomain_name ) ;
35
+ url . pathname = "/" ;
36
+
37
+ href = url . toString ( ) ;
33
38
}
34
39
return href ;
35
40
} ;
Original file line number Diff line number Diff line change @@ -12,7 +12,12 @@ export const portForwardURL = (
12
12
const suffix = protocol === "https" ? "s" : "" ;
13
13
14
14
const subdomain = `${ port } ${ suffix } --${ agentName } --${ workspaceName } --${ username } ` ;
15
- return `${ location . protocol } //${ host } ` . replace ( "*" , subdomain ) ;
15
+
16
+ const baseUrl = `${ location . protocol } //${ host } ` ;
17
+ const url = new URL ( baseUrl ) ;
18
+ url . hostname = host . replace ( "*" , subdomain ) ;
19
+
20
+ return url . toString ( ) ;
16
21
} ;
17
22
18
23
// openMaybePortForwardedURL tries to open the provided URI through the
You can’t perform that action at this time.
0 commit comments