Skip to content

Commit 3f9b398

Browse files
committed
[chrome] fix internal urls not showing in url bar
1 parent c89f140 commit 3f9b398

File tree

2 files changed

+43
-23
lines changed

2 files changed

+43
-23
lines changed

packages/chrome/src/components/Omnibar/UrlInput.tsx

Lines changed: 42 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { splitUrl } from "../../utils";
77
import { OmnibarButton } from "./OmnibarButton";
88
import { BookmarkButton } from "./BookmarkButton";
99

10-
export function UrlInput(s: {
10+
export function UrlInput(props: {
1111
active: boolean;
1212
favicon: string | null;
1313
url: URL;
@@ -20,56 +20,76 @@ export function UrlInput(s: {
2020
doSearch?: () => void;
2121
}) {
2222
return (
23-
<div class:active={use(s.active)}>
23+
<div class:active={use(props.active)}>
2424
<div class="lefticon">
25-
{use(s.active).andThen(
26-
use(s.favicon).andThen(
27-
<Favicon url={s.favicon}></Favicon>,
25+
{use(props.active).andThen(
26+
use(props.favicon).andThen(
27+
<Favicon url={props.favicon}></Favicon>,
2828
<Icon icon={iconSearch}></Icon>
2929
),
3030
<SiteOptionsButton></SiteOptionsButton>
3131
)}
3232
</div>
33-
{use(s.active).andThen(
33+
{use(props.active).andThen(
3434
<input
3535
spellcheck="false"
36-
this={use(s.input)}
37-
value={use(s.value)}
36+
this={use(props.input)}
37+
value={use(props.value)}
3838
on:keydown={(e: KeyboardEvent) => {
39-
s.onkeydown?.(e);
39+
props.onkeydown?.(e);
4040
}}
4141
on:keyup={(e: KeyboardEvent) => {
42-
s.onkeyup?.(e);
42+
props.onkeyup?.(e);
4343
}}
4444
on:input={(e: InputEvent) => {
45-
s.oninput?.(e);
45+
props.oninput?.(e);
4646
}}
4747
></input>
4848
)}
49-
{use(s.active, s.url)
49+
{use(props.active, props.url)
5050
.map(([active, url]) => !active && url.href != "puter://newtab")
5151
.andThen(
5252
<span class="inactiveurl">
53-
<span class="subdomain">
54-
{use(s.url).map((t) => splitUrl(t)[0])}
55-
</span>
56-
<span class="domain">{use(s.url).map((t) => splitUrl(t)[1])}</span>
57-
<span class="rest">{use(s.url).map((t) => splitUrl(t)[2])}</span>
53+
{use(props.url)
54+
.map((u) => u.protocol === "puter:")
55+
.andThen(
56+
<>
57+
<span class="subdomain">puter://</span>
58+
<span class="domain">
59+
{use(props.url).map((t) => t.hostname)}
60+
</span>
61+
<span class="rest">
62+
{use(props.url).map((t) => t.pathname + t.search + t.hash)}
63+
</span>
64+
</>,
65+
<>
66+
<span class="subdomain">
67+
{use(props.url).map((t) => console.log(t, splitUrl(t)))}
68+
{use(props.url).map((t) => splitUrl(t)[0])}
69+
</span>
70+
<span class="domain">
71+
{use(props.url).map((t) => splitUrl(t)[1])}
72+
</span>
73+
<span class="rest">
74+
{use(props.url).map((t) => splitUrl(t)[2])}
75+
</span>
76+
</>
77+
)}
5878
</span>
5979
)}
60-
{use(s.active, s.url)
80+
{use(props.active, props.url)
6181
.map(([active, url]) => !active && url.href == "puter://newtab")
6282
.andThen(
6383
<span class="placeholder">Search with Google or enter address</span>
6484
)}
6585

66-
{use(s.active)
86+
{use(props.active)
6787
.map((a) => !a)
68-
.andThen(<BookmarkButton url={use(s.url)}></BookmarkButton>)}
69-
{use(s.active).andThen(
88+
.andThen(<BookmarkButton url={use(props.url)}></BookmarkButton>)}
89+
{use(props.active).andThen(
7090
<OmnibarButton
7191
click={(e: MouseEvent) => {
72-
s.doSearch?.();
92+
props.doSearch?.();
7393
e.stopPropagation();
7494
e.preventDefault();
7595
}}

packages/chrome/src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export function splitUrl(url: URL): [string, string, string] {
5353
if (last == "/") last = "";
5454

5555
let results = parse(url.href);
56-
let domain = results.domain;
56+
let domain = results.domain || results.hostname;
5757
if (domain && url.port) {
5858
domain += ":" + url.port;
5959
}

0 commit comments

Comments
 (0)