detached 5ee1115

feat(url): add normalize utility for url scheme handling

commit
5ee1115980bbbeefa0afbb02d92c8773a3ba3cee
author
bnema · · 2025-12-18 03:51 UTC
parent
9c927bd
signature
unsigned
1 file · +43 -0
A internal/domain/url/normalize.go +43 -0
@@ -0,0 +1,43 @@
1+// Package url provides URL manipulation utilities for the browser.
2+package url
3+
4+import "strings"
5+
6+// Normalize adds https:// prefix if missing for URL-like inputs.
7+// Returns the input unchanged if it already has a scheme or doesn't look like a URL.
8+func Normalize(input string) string {
9+ if input == "" {
10+ return ""
11+ }
12+
13+ // Already has scheme
14+ switch {
15+ case strings.HasPrefix(input, "http://"):
16+ return input
17+ case strings.HasPrefix(input, "https://"):
18+ return input
19+ case strings.HasPrefix(input, "dumb://"):
20+ return input
21+ case strings.HasPrefix(input, "file://"):
22+ return input
23+ case strings.HasPrefix(input, "about:"):
24+ return input
25+ }
26+
27+ // Looks like a URL (contains . and no spaces)
28+ if strings.Contains(input, ".") && !strings.Contains(input, " ") {
29+ return "https://" + input
30+ }
31+
32+ return input
33+}
34+
35+// LooksLikeURL checks if the input appears to be a URL (not a search query).
36+// Returns true for strings like "github.com", "google.com/search", etc.
37+func LooksLikeURL(input string) bool {
38+ if input == "" {
39+ return false
40+ }
41+ // Contains a dot and no spaces = likely a URL
42+ return strings.Contains(input, ".") && !strings.Contains(input, " ")
43+}
@@ -0,0 +1,43 @@
1+// Package url provides URL manipulation utilities for the browser.
2+package url
3+
4+import "strings"
5+
6+// Normalize adds https:// prefix if missing for URL-like inputs.
7+// Returns the input unchanged if it already has a scheme or doesn't look like a URL.
8+func Normalize(input string) string {
9+ if input == "" {
10+ return ""
11+ }
12+
13+ // Already has scheme
14+ switch {
15+ case strings.HasPrefix(input, "http://"):
16+ return input
17+ case strings.HasPrefix(input, "https://"):
18+ return input
19+ case strings.HasPrefix(input, "dumb://"):
20+ return input
21+ case strings.HasPrefix(input, "file://"):
22+ return input
23+ case strings.HasPrefix(input, "about:"):
24+ return input
25+ }
26+
27+ // Looks like a URL (contains . and no spaces)
28+ if strings.Contains(input, ".") && !strings.Contains(input, " ") {
29+ return "https://" + input
30+ }
31+
32+ return input
33+}
34+
35+// LooksLikeURL checks if the input appears to be a URL (not a search query).
36+// Returns true for strings like "github.com", "google.com/search", etc.
37+func LooksLikeURL(input string) bool {
38+ if input == "" {
39+ return false
40+ }
41+ // Contains a dot and no spaces = likely a URL
42+ return strings.Contains(input, ".") && !strings.Contains(input, " ")
43+}

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 8

Tags 42

↑↓ moveenter openesc close