File tree Expand file tree Collapse file tree 5 files changed +103
-11
lines changed
Expand file tree Collapse file tree 5 files changed +103
-11
lines changed Original file line number Diff line number Diff line change 2626 "react-icons" : " 4.12.0" ,
2727 "react-markdown" : " 9.0.1" ,
2828 "rehype-raw" : " 7.0.0" ,
29- "remark-gfm" : " 4.0.0"
29+ "remark-gfm" : " 4.0.0" ,
30+ "sanitize-html" : " 2.13.1"
3031 },
3132 "devDependencies" : {
3233 "@types/lodash" : " 4.17.13" ,
3334 "@types/node" : " 20.17.6" ,
3435 "@types/react" : " 18.3.12" ,
3536 "@types/react-dom" : " 18.3.1" ,
37+ "@types/sanitize-html" : " 2.13.0" ,
3638 "eslint" : " 8.57.1" ,
3739 "eslint-config-next" : " 14.2.16" ,
3840 "prettier" : " 3.3.3" ,
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ import { MdMenu } from "react-icons/md";
3838import ReactMarkdown from "react-markdown" ;
3939import rehypeRaw from "rehype-raw" ;
4040import remarkGfm from "remark-gfm" ;
41+ import sanitizeHtml from "sanitize-html" ;
4142
4243type FilePath = string ;
4344type UrlPath = string ;
@@ -194,10 +195,6 @@ const getNavigation = (manifest: Manifest): Nav => {
194195 return navigation ;
195196} ;
196197
197- const removeHtmlComments = ( string : string ) => {
198- return string . replace ( / < ! - - [ \s \S ] * ?- - > / g, "" ) ;
199- } ;
200-
201198export const getStaticPaths : GetStaticPaths = ( ) => {
202199 const manifest = getManifest ( ) ;
203200 const routes = mapRoutes ( manifest ) ;
@@ -221,7 +218,7 @@ export const getStaticProps: GetStaticProps = (context) => {
221218 const route = routes [ urlPath ] ;
222219 const { body } = fm ( readContentFile ( route . path ) ) ;
223220 // Serialize MDX to support custom components
224- const content = removeHtmlComments ( body ) ;
221+ const content = sanitizeHtml ( body ) ;
225222 const navigation = getNavigation ( manifest ) ;
226223 const version = manifest . versions [ 0 ] ;
227224
Original file line number Diff line number Diff line change @@ -29,7 +29,12 @@ export const createAppLinkHref = (
2929 }
3030
3131 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 ( ) ;
3338 }
3439 return href ;
3540} ;
Original file line number Diff line number Diff line change @@ -12,7 +12,12 @@ export const portForwardURL = (
1212 const suffix = protocol === "https" ? "s" : "" ;
1313
1414 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 ( ) ;
1621} ;
1722
1823// openMaybePortForwardedURL tries to open the provided URI through the
You can’t perform that action at this time.
0 commit comments