v0.3.0 8f98fd3

urlorigin_test.go RawHistoryFolder

1// SPDX-License-Identifier: MIT
2
3package urlorigin
4
5import "testing"
6
7func TestCanonical(t *testing.T) {
8	for in, want := range map[string]string{
9		"https://Ermite.example/x":     "https://ermite.example:443",
10		"HTTPS://ermite.example":       "https://ermite.example:443",
11		"https://ermite.example:443/x": "https://ermite.example:443",
12		"http://a.test:80":             "http://a.test:80",
13		"http://a.test":                "http://a.test:80",
14		"http://a.test:8088/p?q#f":     "http://a.test:8088",
15		"https://[::1]:8443/x":         "https://[::1]:8443",
16		"https://[::1]/x":              "https://[::1]:443",
17		"https://[::1]:443":            "https://[::1]:443",
18		"https://[2001:DB8::1]:8443":   "https://[2001:db8::1]:8443",
19		"http://[::1]:80":              "http://[::1]:80",
20		"http://10.0.2.2:8088":         "http://10.0.2.2:8088",
21		"ftp://a.test":                 "", "a.test": "", "https://u@a.test": "", "https://u:p@a.test": "", "": "", "https://": "", "//a.test": "",
22		"https://[::1:8443]/x": "https://[::1:8443]:443", // an IPv6 host with no port at all
23	} {
24		if got := Canonical(in); got != want {
25			t.Errorf("Canonical(%q) = %q, want %q", in, got, want)
26		}
27	}
28	// GO-012: the host ::1 on port 8443 is not the host ::1:8443.
29	if Canonical("https://[::1]:8443/x") == Canonical("https://[::1:8443]/x") {
30		t.Error("two different origins collide")
31	}
32	// Spellings of one origin agree.
33	for _, pair := range [][2]string{
34		{"https://a.test", "https://A.TEST:443/path"}, {"http://a.test:80/", "http://a.test"}, {"https://[::1]", "https://[::1]:443"},
35	} {
36		if Canonical(pair[0]) != Canonical(pair[1]) {
37			t.Errorf("%q and %q differ: %q %q", pair[0], pair[1], Canonical(pair[0]), Canonical(pair[1]))
38		}
39	}
40	// Other ports, schemes and hosts differ.
41	for _, pair := range [][2]string{
42		{"https://a.test", "http://a.test"}, {"https://a.test", "https://a.test:8443"}, {"https://a.test", "https://b.a.test"}, {"http://a.test", "http://a.test:443"},
43	} {
44		if Canonical(pair[0]) == Canonical(pair[1]) {
45			t.Errorf("%q and %q collide", pair[0], pair[1])
46		}
47	}
48}
49
50func TestPrefix(t *testing.T) {
51	for in, want := range map[string]string{
52		"https://Ermite.example:443/x": "https://ermite.example", "http://a.test:80": "http://a.test", "http://a.test:8088": "http://a.test:8088",
53		"https://[::1]:443": "https://[::1]", "http://[::1]:80/": "http://[::1]", "https://[::1]:8443": "https://[::1]:8443",
54		"http://10.0.2.2:8088": "http://10.0.2.2:8088", "https://a.test:80": "https://a.test:80", "ftp://x": "",
55	} {
56		if got := Prefix(in); got != want {
57			t.Errorf("Prefix(%q) = %q, want %q", in, got, want)
58		}
59	}
60}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 4

Tags 11

↑↓ moveenter openesc close