Skip to content

Commit 5a9e454

Browse files
committed
Default app-name once
1 parent 2a1bfc8 commit 5a9e454

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

src/node/cli.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,7 @@ export interface DefaultedArgs extends ConfigArgs {
519519
"extensions-dir": string
520520
"user-data-dir": string
521521
"session-socket": string
522+
"app-name": string
522523
/* Positional arguments. */
523524
_: string[]
524525
}
@@ -665,6 +666,10 @@ export async function setDefaults(cliArgs: UserProvidedArgs, configArgs?: Config
665666
}
666667
args["proxy-domain"] = finalProxies
667668

669+
if (!args["app-name"]) {
670+
args["app-name"] = "code-server"
671+
}
672+
668673
args._ = getResolvedPathsFromArgs(args)
669674

670675
return {

src/node/routes/errors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export const errorHandler: express.ErrorRequestHandler = async (err, req, res, n
5858
.replace(/{{ERROR_TITLE}}/g, statusCode.toString())
5959
.replace(/{{ERROR_HEADER}}/g, statusCode.toString())
6060
.replace(/{{ERROR_BODY}}/g, escapeHtml(err.message))
61-
.replace(/{{APP_NAME}}/g, (req.args && req.args["app-name"]) || "code-server"),
61+
.replace(/{{APP_NAME}}/g, req.args["app-name"]),
6262
)
6363
} else {
6464
res.json({

src/node/routes/login.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ const getRoot = async (req: Request, error?: Error): Promise<string> => {
2929
const content = await fs.readFile(path.join(rootPath, "src/browser/pages/login.html"), "utf8")
3030
const locale = req.args["locale"] || "en"
3131
i18n.changeLanguage(locale)
32-
const appName = req.args["app-name"] || "code-server"
33-
const welcomeText = req.args["welcome-text"] || (i18n.t("WELCOME", { app: appName }) as string)
32+
const welcomeText = req.args["welcome-text"] || (i18n.t("WELCOME", { app: req.args["app-name"] }) as string)
3433

3534
// Determine password message using i18n
3635
let passwordMsg = i18n.t("LOGIN_PASSWORD", { configFile: req.args.config })
@@ -43,7 +42,7 @@ const getRoot = async (req: Request, error?: Error): Promise<string> => {
4342
return replaceTemplates(
4443
req,
4544
content
46-
.replace(/{{I18N_LOGIN_TITLE}}/g, i18n.t("LOGIN_TITLE", { app: appName }))
45+
.replace(/{{I18N_LOGIN_TITLE}}/g, i18n.t("LOGIN_TITLE", { app: req.args["app-name"] }))
4746
.replace(/{{WELCOME_TEXT}}/g, welcomeText)
4847
.replace(/{{PASSWORD_MSG}}/g, passwordMsg)
4948
.replace(/{{I18N_LOGIN_BELOW}}/g, i18n.t("LOGIN_BELOW"))

src/node/routes/vscode.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,16 +172,15 @@ router.get("/", ensureVSCodeLoaded, async (req, res, next) => {
172172
})
173173

174174
router.get("/manifest.json", async (req, res) => {
175-
const appName = req.args["app-name"] || "code-server"
176175
res.writeHead(200, { "Content-Type": "application/manifest+json" })
177176

178177
res.end(
179178
replaceTemplates(
180179
req,
181180
JSON.stringify(
182181
{
183-
name: appName,
184-
short_name: appName,
182+
name: req.args["app-name"],
183+
short_name: req.args["app-name"],
185184
start_url: ".",
186185
display: "fullscreen",
187186
display_override: ["window-controls-overlay"],

0 commit comments

Comments
 (0)