Skip to content

Commit fa9bc0a

Browse files
authored
Merge branch 'main' into main
2 parents a39d13c + eb314ff commit fa9bc0a

File tree

8 files changed

+80
-20
lines changed

8 files changed

+80
-20
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ jobs:
509509
fetch-depth: 0
510510

511511
- name: Run Trivy vulnerability scanner in repo mode
512-
uses: aquasecurity/trivy-action@df3fb7d00b594d641478ba45b867f5cbb32108be
512+
uses: aquasecurity/trivy-action@e27605859b9550f81ddd818eb816c8cb83cf9650
513513
with:
514514
scan-type: "fs"
515515
scan-ref: "."

.github/workflows/docker.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ jobs:
4747
run: echo "::set-output name=version::$(jq -r .version package.json)"
4848

4949
- name: Download release artifacts
50-
uses: robinraju/release-downloader@v1.3
50+
uses: robinraju/release-downloader@v1.4
5151
with:
5252
repository: "coder/code-server"
5353
tag: v${{ steps.version.outputs.version }}
54-
fileName: "*"
54+
fileName: "*.deb"
5555
out-file-path: "release-packages"
5656

5757
- name: Publish to Docker

.github/workflows/trivy-docker.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
uses: actions/checkout@v3
5252

5353
- name: Run Trivy vulnerability scanner in image mode
54-
uses: aquasecurity/trivy-action@df3fb7d00b594d641478ba45b867f5cbb32108be
54+
uses: aquasecurity/trivy-action@e27605859b9550f81ddd818eb816c8cb83cf9650
5555
with:
5656
image-ref: "docker.io/codercom/code-server:latest"
5757
ignore-unfixed: true

docs/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ access it in the browser.
1414
- Preserve battery life when you're on the go; all intensive tasks run on your
1515
server
1616

17-
| 🔔 code-server is a free browser-based IDE while [Coder](https://coder.com/) is our enterprise developer workspace platform. For more information, visit [Coder.com](https://coder.com/docs/comparison)
18-
| ---
17+
> **Note**
18+
> To manage multiple IDEs, workspaces, and teams, see
19+
> our new project: [coder/coder](http://cdr.co/coder-github)
1920
2021
## Requirements
2122

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
"limiter": "^1.1.5",
101101
"pem": "^1.14.2",
102102
"proxy-agent": "^5.0.0",
103-
"qs": "6.10.3",
103+
"qs": "6.10.5",
104104
"rotating-file-stream": "^3.0.0",
105105
"safe-buffer": "^5.1.1",
106106
"safe-compare": "^1.1.4",

src/node/util.ts

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,37 @@ export const isWsl = async (
404404
}
405405
}
406406

407+
interface OpenOptions {
408+
args: string[]
409+
command: string
410+
urlSearch: string
411+
}
412+
413+
/**
414+
* A helper function to construct options for `open` function.
415+
*
416+
* Extract to make it easier to test.
417+
*
418+
* @param platform - platform on machine
419+
* @param urlSearch - url.search
420+
* @returns an object with args, command, options and urlSearch
421+
*/
422+
export function constructOpenOptions(platform: NodeJS.Platform | "wsl", urlSearch: string): OpenOptions {
423+
const args: string[] = []
424+
let command = platform === "darwin" ? "open" : "xdg-open"
425+
if (platform === "win32" || platform === "wsl") {
426+
command = platform === "wsl" ? "cmd.exe" : "cmd"
427+
args.push("/c", "start", '""', "/b")
428+
urlSearch = urlSearch.replace(/&/g, "^&")
429+
}
430+
431+
return {
432+
args,
433+
command,
434+
urlSearch,
435+
}
436+
}
437+
407438
/**
408439
* Try opening an address using whatever the system has set for opening URLs.
409440
*/
@@ -416,16 +447,10 @@ export const open = async (address: URL | string): Promise<void> => {
416447
if (url.hostname === "0.0.0.0") {
417448
url.hostname = "localhost"
418449
}
419-
const args = [] as string[]
420-
const options = {} as cp.SpawnOptions
421450
const platform = (await isWsl(process.platform, os.release(), "/proc/version")) ? "wsl" : process.platform
422-
let command = platform === "darwin" ? "open" : "xdg-open"
423-
if (platform === "win32" || platform === "wsl") {
424-
command = platform === "wsl" ? "cmd.exe" : "cmd"
425-
args.push("/c", "start", '""', "/b")
426-
url.search = url.search.replace(/&/g, "^&")
427-
}
428-
const proc = cp.spawn(command, [...args, url.toString()], options)
451+
const { command, args, urlSearch } = constructOpenOptions(platform, url.search)
452+
url.search = urlSearch
453+
const proc = cp.spawn(command, [...args, url.toString()], {})
429454
await new Promise<void>((resolve, reject) => {
430455
proc.on("error", reject)
431456
proc.on("close", (code) => {

test/unit/node/util.test.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,3 +544,37 @@ describe("open", () => {
544544
await expect(util.open(address)).rejects.toThrow("Cannot open socket paths")
545545
})
546546
})
547+
describe("constructOpenOptions", () => {
548+
it("should return options for darwin", () => {
549+
const platform: NodeJS.Platform | "wsl" = "darwin"
550+
const url = new URL("localhost:8080")
551+
const { args, command, urlSearch } = util.constructOpenOptions(platform, url.search)
552+
expect(args).toStrictEqual([])
553+
expect(command).toBe("open")
554+
expect(urlSearch).toBe("")
555+
})
556+
it("should return options for linux", () => {
557+
const platform: NodeJS.Platform | "wsl" = "linux"
558+
const url = new URL("localhost:8080")
559+
const { args, command, urlSearch } = util.constructOpenOptions(platform, url.search)
560+
expect(args).toStrictEqual([])
561+
expect(command).toBe("xdg-open")
562+
expect(urlSearch).toBe("")
563+
})
564+
it("should return options for win32", () => {
565+
const platform: NodeJS.Platform | "wsl" = "win32"
566+
const url = new URL("localhost:8080?q=&test")
567+
const { args, command, urlSearch } = util.constructOpenOptions(platform, url.search)
568+
expect(args).toStrictEqual(["/c", "start", '""', "/b"])
569+
expect(command).toBe("cmd")
570+
expect(urlSearch).toBe("?q=^&test")
571+
})
572+
it("should return options for wsl", () => {
573+
const platform: NodeJS.Platform | "wsl" = "wsl"
574+
const url = new URL("localhost:8080?q=&test")
575+
const { args, command, urlSearch } = util.constructOpenOptions(platform, url.search)
576+
expect(args).toStrictEqual(["/c", "start", '""', "/b"])
577+
expect(command).toBe("cmd.exe")
578+
expect(urlSearch).toBe("?q=^&test")
579+
})
580+
})

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3513,10 +3513,10 @@ punycode@^2.1.0:
35133513
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec"
35143514
integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==
35153515

3516-
3517-
version "6.10.3"
3518-
resolved "https://registry.yarnpkg.com/qs/-/qs-6.10.3.tgz#d6cde1b2ffca87b5aa57889816c5f81535e22e8e"
3519-
integrity sha512-wr7M2E0OFRfIfJZjKGieI8lBKb7fRCH4Fv5KNPEs7gJ8jadvotdsS08PzOKR7opXhZ/Xkjtt3WF9g38drmyRqQ==
3516+
3517+
version "6.10.5"
3518+
resolved "https://registry.yarnpkg.com/qs/-/qs-6.10.5.tgz#974715920a80ff6a262264acd2c7e6c2a53282b4"
3519+
integrity sha512-O5RlPh0VFtR78y79rgcgKK4wbAI0C5zGVLztOIdpWX6ep368q5Hv6XRxDvXuZ9q3C6v+e3n8UfZZJw7IIG27eQ==
35203520
dependencies:
35213521
side-channel "^1.0.4"
35223522

0 commit comments

Comments
 (0)