From 65b97824861faaabb21d44bc3a1820994ba74377 Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Fri, 6 Dec 2024 12:07:18 -0800 Subject: [PATCH] Clean up the shorts list --- main.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 4d7cb79..116a559 100644 --- a/main.go +++ b/main.go @@ -288,9 +288,17 @@ func (sl *ShortLinks) serveSuggest(w http.ResponseWriter, r *http.Request) { return } - out.Domain = sl.getDomain(r.Host) + send := &suggestResponse{ + Domain: sl.getDomain(r.Host), + } - sendJSON(w, out) + for _, short := range out.Shorts { + if short != "" { + send.Shorts = append(send.Shorts, strings.ToLower(strings.TrimSpace(short))) + } + } + + sendJSON(w, send) } func (sl *ShortLinks) serveHelp(w http.ResponseWriter, r *http.Request) {