aboutsummaryrefslogtreecommitdiff
path: root/util/util.go
diff options
context:
space:
mode:
authorKushBlazingJudah <59340248+KushBlazingJudah@users.noreply.github.com>2021-11-02 14:55:59 -0300
committerFChannel <>2022-06-19 12:53:29 -0700
commit36a41e03c59624a2b4a7eb174e9a003e288a1d7d (patch)
tree149c72f53b4fe41308ebc1624ed46037760254e0 /util/util.go
parentfbf9732a7a7a599fdc35b7e9e2072d32d2ea9d33 (diff)
restructuring, part 4 of many
Diffstat (limited to 'util/util.go')
-rw-r--r--util/util.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/util/util.go b/util/util.go
index 7164937..4ac8267 100644
--- a/util/util.go
+++ b/util/util.go
@@ -12,3 +12,40 @@ func IsOnion(url string) bool {
return false
}
+
+func GetActorInstance(path string) (string, string) {
+ re := regexp.MustCompile(`([@]?([\w\d.-_]+)[@](.+))`)
+ atFormat := re.MatchString(path)
+
+ if atFormat {
+ match := re.FindStringSubmatch(path)
+ if len(match) > 2 {
+ return match[2], match[3]
+ }
+ }
+
+ re = regexp.MustCompile(`(https?://)(www)?([\w\d-_.:]+)(/|\s+|\r|\r\n)?$`)
+ mainActor := re.MatchString(path)
+ if mainActor {
+ match := re.FindStringSubmatch(path)
+ if len(match) > 2 {
+ return "main", match[3]
+ }
+ }
+
+ re = regexp.MustCompile(`(https?://)?(www)?([\w\d-_.:]+)\/([\w\d-_.]+)(\/([\w\d-_.]+))?`)
+ httpFormat := re.MatchString(path)
+
+ if httpFormat {
+ match := re.FindStringSubmatch(path)
+ if len(match) > 3 {
+ if match[4] == "users" {
+ return match[6], match[3]
+ }
+
+ return match[4], match[3]
+ }
+ }
+
+ return "", ""
+}