summaryrefslogtreecommitdiff
path: root/internal/utils/safe_redirection.go
blob: d161c8b3649412c5dc05a224947060be830ac8b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package utils

import (
	"net/url"
	"strings"
)

// IsRedirectionSafe determines if a redirection URL is secured.
func IsRedirectionSafe(url url.URL, protectedDomain string) bool {
	if url.Scheme != "https" {
		return false
	}

	if !strings.HasSuffix(url.Hostname(), protectedDomain) {
		return false
	}

	return true
}