Skip to content

Commit 751a5ea

Browse files
committed
Move login JS to a separate file
Mostly so the base URL resolution code can be shared.
1 parent de568d4 commit 751a5ea

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

ci/build/build-code-server.sh

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ main() {
2121
--public-url "." \
2222
--out-dir dist \
2323
$([[ $MINIFY ]] || echo --no-minify) \
24+
src/browser/login.ts \
2425
src/browser/register.ts \
2526
src/browser/serviceWorker.ts
2627
}

ci/dev/watch.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,11 @@ class Watcher {
164164

165165
private createBundler(out = "dist"): Bundler {
166166
return new Bundler(
167-
[path.join(this.rootPath, "src/browser/register.ts"), path.join(this.rootPath, "src/browser/serviceWorker.ts")],
167+
[
168+
path.join(this.rootPath, "src/browser/login.ts"),
169+
path.join(this.rootPath, "src/browser/register.ts"),
170+
path.join(this.rootPath, "src/browser/serviceWorker.ts"),
171+
],
168172
{
169173
outDir: path.join(this.rootPath, out),
170174
cacheDir: path.join(this.rootPath, ".cache"),

src/browser/pages/login.html

+1-6
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,5 @@ <h1 class="main">Welcome to code-server</h1>
4747
</div>
4848
</body>
4949
<script data-cfasync="false" src="{{CS_STATIC_BASE}}/dist/register.js"></script>
50-
<script>
51-
const parts = window.location.pathname.replace(/^\//g, "").split("/")
52-
parts[parts.length - 1] = "{{BASE}}"
53-
const url = new URL(window.location.origin + "/" + parts.join("/"))
54-
document.getElementById("base").value = url.pathname
55-
</script>
50+
<script data-cfasync="false" src="{{CS_STATIC_BASE}}/dist/login.js"></script>
5651
</html>

src/browser/pages/login.ts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { getOptions } from "../../common/util"
2+
3+
const options = getOptions()
4+
const el = document.getElementById("base") as HTMLInputElement
5+
if (el) {
6+
el.value = options.base
7+
}

0 commit comments

Comments
 (0)