WIP
This commit is contained in:
parent
09cb1482b4
commit
466c9874a8
6 changed files with 114 additions and 76 deletions
10
util/util.go
10
util/util.go
|
@ -172,6 +172,16 @@ func ShortTopicURL(s string) string {
|
|||
return strings.TrimPrefix(strings.TrimPrefix(s, "https://"), "http://")
|
||||
}
|
||||
|
||||
// ExpandTopicURL expands a topic to a fully qualified URL, e.g. "mytopic" -> "https://ntfy.sh/mytopic"
|
||||
func ExpandTopicURL(topic, defaultHost string) string {
|
||||
if strings.HasPrefix(topic, "http://") || strings.HasPrefix(topic, "https://") {
|
||||
return topic
|
||||
} else if strings.Contains(topic, "/") {
|
||||
return fmt.Sprintf("https://%s", topic)
|
||||
}
|
||||
return fmt.Sprintf("%s/%s", defaultHost, topic)
|
||||
}
|
||||
|
||||
// DetectContentType probes the byte array b and returns mime type and file extension.
|
||||
// The filename is only used to override certain special cases.
|
||||
func DetectContentType(b []byte, filename string) (mimeType string, ext string) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue