Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Merge pull request #56 from nalysius/parse-signal-group-url
Browse files Browse the repository at this point in the history
Parse a Signal group URL
  • Loading branch information
nanu-c committed May 7, 2022
2 parents 53684eb + 5e1bc08 commit ea71697
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion groupsv2/groupsv2.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/hex"
"fmt"
"io/ioutil"
"net/url"
"os"
"path/filepath"

Expand Down Expand Up @@ -33,7 +34,7 @@ const (
)

var (
groupURLHost = "group.signal.org"
groupURLHost = "signal.group"
groupURLPrefix = "https://" + groupURLHost + "/#"
groupV2Dir string
groupsV2 = map[string]*GroupV2{}
Expand All @@ -58,6 +59,33 @@ func idToHex(id []byte) string {
return hex.EncodeToString(id)
}

// Parse an arbitrary string to a Signal group URL.
// If the URL is invalid, nil is returned.
func getGroupUrl(uriString string) *url.URL {
url, err := url.Parse(uriString)
if err != nil {
log.Errorln("[textsecure][groupsv2] GroupInviteLinkUrl error parsing URL", err)
return nil
}
if url.Scheme != "https" {
log.Errorln("[textsecure][groupsv2] GroupInviteLinkUrl URL invalid scheme ", url.Scheme)
return nil
}
if url.Host != groupURLHost {
log.Errorln("[textsecure][groupsv2] GroupInviteLinkUrl URL invalid host ", url.Host)
return nil
}
if url.Path != "" {
log.Errorln("[textsecure][groupsv2] GroupInviteLinkUrl URL path should be empty ", url.Path)
return nil
}
if url.Fragment == "" {
log.Errorln("[textsecure][groupsv2] GroupInviteLinkUrl URL fragment is empty ")
return nil
}
return url
}

func GroupInviteLinkUrl() {

}
Expand Down

0 comments on commit ea71697

Please sign in to comment.