diff options
author | FChannel <> | 2021-04-26 12:24:14 -0700 |
---|---|---|
committer | FChannel <> | 2021-04-26 12:24:14 -0700 |
commit | 4bd1944ae847a44ec8cd1996dc26145f6af08ead (patch) | |
tree | bdb4b836187ed46d5f0dffc76b26e68562450ff3 /main.go | |
parent | a07341569819f7f55d9e8b86db02c7e5ae9e8ba4 (diff) |
noko fix
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 59 |
1 files changed, 45 insertions, 14 deletions
@@ -1930,31 +1930,65 @@ func GetActorCollectionReq(r *http.Request, collection string) Collection { func shortURL(actorName string, url string) string { - re := regexp.MustCompile(`outbox`) + re := regexp.MustCompile(`.+\/`) + + actor := re.FindString(actorName) + + urlParts := strings.Split(url, "|") + + op := urlParts[0] + + var reply string + + if len(urlParts) > 1 { + reply = urlParts[1] + } - actor := re.ReplaceAllString(actorName, "") - re = regexp.MustCompile(`\w+$`) - temp := re.ReplaceAllString(url, "") + temp := re.ReplaceAllString(op, "") if(temp == actor){ - short := StripTransferProtocol(url) + id := localShort(op) - re := regexp.MustCompile(`\w+$`) + re := regexp.MustCompile(`.+\/`) + replyCheck := re.FindString(reply) - id := re.FindString(short); + if(reply != "" && replyCheck == actor){ + id = id + "#" + localShort(reply) + } else if reply != "" { + id = id + "#" + remoteShort(reply) + } return id; }else{ - short := StripTransferProtocol(url) + id := remoteShort(op) + + re := regexp.MustCompile(`.+\/`) + replyCheck := re.FindString(reply) + + if(reply != "" && replyCheck == actor){ + id = id + "#" + localShort(reply) + } else if reply != "" { + id = id + "#" + remoteShort(reply) + } + + return id; + } +} +func localShort(url string) string { re := regexp.MustCompile(`\w+$`) + return re.FindString(StripTransferProtocol(url)); +} - id := re.FindString(short); +func remoteShort(url string) string { + re := regexp.MustCompile(`\w+$`) + + id := re.FindString(StripTransferProtocol(url)); re = regexp.MustCompile(`.+/.+/`) - actorurl := re.FindString(short) + actorurl := re.FindString(StripTransferProtocol(url)) re = regexp.MustCompile(`/.+/`) @@ -1962,8 +1996,5 @@ func shortURL(actorName string, url string) string { actorname = strings.Replace(actorname, "/", "", -1) - id = "f" + actorname + "-" + id - - return id; - } + return "f" + actorname + "-" + id } |