Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

feat(url): Add default url title

LinkinStarsb4f61190b074
diff --git a/pkg/htmltext/htmltext.go b/pkg/htmltext/htmltext.go
index 792063f4..9e847d6a 100644
--- a/pkg/htmltext/htmltext.go
+++ b/pkg/htmltext/htmltext.go
@@ -20,14 +20,15 @@
package htmltext
import (
- "github.com/Chain-Zhang/pinyin"
- "github.com/apache/incubator-answer/pkg/checker"
"io"
"net/http"
"net/url"
"regexp"
"strings"
+ "github.com/Chain-Zhang/pinyin"
+ "github.com/apache/incubator-answer/pkg/checker"
+
"github.com/Machiel/slugify"
strip "github.com/grokify/html-strip-tags-go"
)
@@ -72,6 +73,9 @@ func UrlTitle(title string) (text string) {
title = slugify.Slugify(title)
title = url.QueryEscape(title)
title = cutLongTitle(title)
+ if len(title) == 0 {
+ title = "topic"
+ }
return title
}