dkforest

A forum and chat platform (onion)
git clone https://git.dasho.dev/n0tr1v/dkforest.git
Log | Files | Refs | LICENSE

commit 4b87b0385e1edc786757f8bd27ab01f18d788973
parent 0a295abba9273de6cb2a283c4e38c750a1d0ed0f
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Sun, 29 Jan 2023 05:52:19 -0800

utility to get a link onion address without scheme or subdomain..

Diffstat:
Mpkg/database/tableLinks.go | 6++++++
1 file changed, 6 insertions(+), 0 deletions(-)

diff --git a/pkg/database/tableLinks.go b/pkg/database/tableLinks.go @@ -5,6 +5,7 @@ import ( "github.com/google/uuid" "github.com/sirupsen/logrus" "html" + "regexp" "time" ) @@ -21,6 +22,11 @@ type Link struct { Mirrors []LinksMirror } +func (l Link) GetOnionAddr() string { + var onionV3Rgx = regexp.MustCompile(`[a-z2-7]{56}\.onion`) + return onionV3Rgx.FindString(l.URL) +} + func (l Link) DescriptionSafe() string { return html.EscapeString(l.Description) }