mirror of
https://github.com/jhillyerd/inbucket.git
synced 2025-12-17 17:47:03 +00:00
- ui: Fix favicon - webui: Changes to support serving Elm UI - Static files now served from `/` mount point. - Old UI handlers moved to `/serve` mount point, some will still be needed by the Elm UI; safe HTML and attachments for example. - Update dev-start.sh for new UI, with tip on how to build it. - ui: Detect browser host:port for websocket URL, - webui: Remove unused mailbox handlers, rename routes - Many routes not needed by Elm UI. - `/serve/mailbox/*` becomes `/serve/m/*`. - webui: Impl custom JSON message API for web UI, - ui: Refactor Mailbox view functions, - ui: Add body tabs for safe HTML and plain text, - webui: Format plain text for new UI, - ui: List attachments with view & download links,
56 lines
1.1 KiB
Go
56 lines
1.1 KiB
Go
package web
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestTextToHtml(t *testing.T) {
|
|
testCases := []struct {
|
|
input, want string
|
|
}{
|
|
{
|
|
input: "html",
|
|
want: "html",
|
|
},
|
|
// Check it escapes.
|
|
{
|
|
input: "<html>",
|
|
want: "<html>",
|
|
},
|
|
// Check for linebreaks.
|
|
{
|
|
input: "line\nbreak",
|
|
want: "line<br/>\nbreak",
|
|
},
|
|
{
|
|
input: "line\r\nbreak",
|
|
want: "line<br/>\nbreak",
|
|
},
|
|
{
|
|
input: "line\rbreak",
|
|
want: "line<br/>\nbreak",
|
|
},
|
|
// Check URL detection.
|
|
{
|
|
input: "http://google.com/",
|
|
want: "<a href=\"http://google.com/\" target=\"_blank\">http://google.com/</a>",
|
|
},
|
|
{
|
|
input: "http://a.com/?q=a&n=v",
|
|
want: "<a href=\"http://a.com/?q=a&n=v\" target=\"_blank\">http://a.com/?q=a&n=v</a>",
|
|
},
|
|
{
|
|
input: "(http://a.com/?q=a&n=v)",
|
|
want: "(<a href=\"http://a.com/?q=a&n=v\" target=\"_blank\">http://a.com/?q=a&n=v</a>)",
|
|
},
|
|
}
|
|
for _, tc := range testCases {
|
|
t.Run(tc.input, func(t *testing.T) {
|
|
got := TextToHTML(tc.input)
|
|
if got != tc.want {
|
|
t.Errorf("TextToHTML(%q)\ngot : %q\nwant: %q", tc.input, got, tc.want)
|
|
}
|
|
})
|
|
}
|
|
}
|