Skip to content

fix: display valid serve URLs for explicit hosts - #16

Merged
lucasnevespereira merged 1 commit into
mainfrom
fix/serve-url
Nov 14, 2026
Merged

lucasnevespereira merged 1 commit into
mainfrom
fix/serve-url

Conversation

@lucasnevespereira

Copy link
Copy Markdown
Member

Summary

inkssg serve always prefixed the address with localhost, so an address with its own host printed a broken URL.

-fmt.Printf("inkssg serving %s on http://localhost%s\n", absDir, o.Addr)
+displayAddr := o.Addr
+if host, port, err := net.SplitHostPort(displayAddr); err == nil && host == "" {
+	displayAddr = net.JoinHostPort("localhost", port)
+}
+fmt.Printf("inkssg serving %s on http://%s\n", absDir, displayAddr)

Evidence

  • Before: inkssg serve my-site --addr 127.0.0.1:4499 printed http://localhost127.0.0.1:4499.
    After:

    • --addr :4497 prints http://localhost:4497
    • --addr 127.0.0.1:4498 prints http://127.0.0.1:4498

    go vet and go test pass.

Merge Danger

Door: two-way

Blast Radius: small

Only the printed URL changes; the server listens on the same address as before.

@lucasnevespereira
lucasnevespereira merged commit 939e50f into main Nov 14, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant