Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitffb0ebb

Browse files
authored
fix: use url-parse for url construction (#15670)
This fixes some CodeQL-flagged issues. They're not real issues but therefactor is small and it'll keep the analysis tools quiet.
1 parent40f12ae commitffb0ebb

File tree

5 files changed

+103
-11
lines changed

5 files changed

+103
-11
lines changed

‎offlinedocs/package.json‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@
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",

‎offlinedocs/pages/[[...slug]].tsx‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import { MdMenu } from "react-icons/md";
3838
importReactMarkdownfrom"react-markdown";
3939
importrehypeRawfrom"rehype-raw";
4040
importremarkGfmfrom"remark-gfm";
41+
importsanitizeHtmlfrom"sanitize-html";
4142

4243
typeFilePath=string;
4344
typeUrlPath=string;
@@ -194,10 +195,6 @@ const getNavigation = (manifest: Manifest): Nav => {
194195
returnnavigation;
195196
};
196197

197-
constremoveHtmlComments=(string:string)=>{
198-
returnstring.replace(/<!--[\s\S]*?-->/g,"");
199-
};
200-
201198
exportconstgetStaticPaths:GetStaticPaths=()=>{
202199
constmanifest=getManifest();
203200
constroutes=mapRoutes(manifest);
@@ -221,7 +218,7 @@ export const getStaticProps: GetStaticProps = (context) => {
221218
constroute=routes[urlPath];
222219
const{ body}=fm(readContentFile(route.path));
223220
// Serialize MDX to support custom components
224-
constcontent=removeHtmlComments(body);
221+
constcontent=sanitizeHtml(body);
225222
constnavigation=getNavigation(manifest);
226223
constversion=manifest.versions[0];
227224

‎offlinedocs/pnpm-lock.yaml‎

Lines changed: 86 additions & 3 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎site/src/utils/apps.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff 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+
constbaseUrl=`${protocol}//${appsHost}`;
33+
consturl=newURL(baseUrl);
34+
url.hostname=appsHost.replace("*",app.subdomain_name);
35+
url.pathname="/";
36+
37+
href=url.toString();
3338
}
3439
returnhref;
3540
};

‎site/src/utils/portForward.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ export const portForwardURL = (
1212
constsuffix=protocol==="https" ?"s" :"";
1313

1414
constsubdomain=`${port}${suffix}--${agentName}--${workspaceName}--${username}`;
15-
return`${location.protocol}//${host}`.replace("*",subdomain);
15+
16+
constbaseUrl=`${location.protocol}//${host}`;
17+
consturl=newURL(baseUrl);
18+
url.hostname=host.replace("*",subdomain);
19+
20+
returnurl.toString();
1621
};
1722

1823
// openMaybePortForwardedURL tries to open the provided URI through the

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp