Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
"@types/wtfnode": "^0.7.0",
"@typescript-eslint/eslint-plugin": "^4.7.0",
"@typescript-eslint/parser": "^4.7.0",
"compression": "^1.7.4",
"doctoc": "^1.4.0",
"eslint": "^7.7.0",
"eslint-config-prettier": "^6.0.0",
Expand All @@ -77,6 +76,7 @@
"dependencies": {
"@coder/logger": "1.1.16",
"body-parser": "^1.19.0",
"compression": "^1.7.4",
"cookie-parser": "^1.4.5",
"env-paths": "^2.2.0",
"express": "^5.0.0-alpha.8",
Expand Down
2 changes: 1 addition & 1 deletion src/node/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ export class PluginAPI {
if (!p.routerPath) {
throw new Error("plugin missing router path")
}
if (!p.routerPath.startsWith("/") || p.routerPath.length < 2) {
if (!p.routerPath.startsWith("/")) {
throw new Error(`plugin router path ${q(p.routerPath)}: invalid`)
}
if (!p.homepageURL) {
Expand Down
23 changes: 23 additions & 0 deletions test/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as express from "express"
import * as fs from "fs"
import * as path from "path"
import { HttpCode } from "../src/common/http"
import { AuthType } from "../src/node/cli"
import { codeServer, PluginAPI } from "../src/node/plugin"
import * as apps from "../src/node/routes/apps"
import * as httpserver from "./httpserver"
Expand All @@ -26,6 +27,28 @@ describe("plugin", () => {

const app = express.default()
const wsApp = express.default()

const common: express.RequestHandler = (req, _, next) => {
// Routes might use these arguments.
req.args = {
_: [],
auth: AuthType.None,
host: "localhost",
port: 8080,
"proxy-domain": [],
config: "~/.config/code-server/config.yaml",
verbose: false,
usingEnvPassword: false,
usingEnvHashedPassword: false,
"extensions-dir": "",
"user-data-dir": "",
}
next()
}

app.use(common)
wsApp.use(common)

papi.mount(app, wsApp)
app.use("/api/applications", apps.router(papi))

Expand Down