diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-12-12 13:23:28 +0100 |
|---|---|---|
| committer | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-12-12 13:39:21 +0100 |
| commit | 4fad9b293210fc1221431f8a9f85e7058850c3ff (patch) | |
| tree | f34aa214156acd609c84f01407d2dc57e9d4314b /internal/util | |
| parent | 5084f1ed5df024918e61de81692b6066c421b8bd (diff) | |
Util: Minor style changes
Diffstat (limited to 'internal/util')
| -rw-r--r-- | internal/util/util.go | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/internal/util/util.go b/internal/util/util.go index 558dba7..01b2f21 100644 --- a/internal/util/util.go +++ b/internal/util/util.go @@ -44,8 +44,8 @@ func EnsureValidURL(s string) (string, error) { // MakeRandomByteSlice creates a cryptographically random bytes slice of `size` // It returns the byte slice (or nil if error) and an error if it could not be generated. -func MakeRandomByteSlice(size int) ([]byte, error) { - bs := make([]byte, size) +func MakeRandomByteSlice(n int) ([]byte, error) { + bs := make([]byte, n) if _, err := rand.Read(bs); err != nil { return nil, errors.WrapPrefix(err, "failed reading random", 0) } @@ -64,27 +64,27 @@ func EnsureDirectory(dir string) error { // ReplaceWAYF replaces an authorization template containing of @RETURN_TO@ and @ORG_ID@ with the authorization URL and the organization ID // See https://github.com/eduvpn/documentation/blob/dc4d53c47dd7a69e95d6650eec408e16eaa814a2/SERVER_DISCOVERY_SKIP_WAYF.md -func ReplaceWAYF(authTplt string, authURL string, orgID string) string { +func ReplaceWAYF(template string, authURL string, orgID string) string { // We just return the authURL in the cases where the template is not given or is invalid - if authTplt == "" { + if template == "" { return authURL } - if !strings.Contains(authTplt, "@RETURN_TO@") { + if !strings.Contains(template, "@RETURN_TO@") { return authURL } - if !strings.Contains(authTplt, "@ORG_ID@") { + if !strings.Contains(template, "@ORG_ID@") { return authURL } // Replace authURL - authTplt = strings.Replace(authTplt, "@RETURN_TO@", url.QueryEscape(authURL), 1) + template = strings.Replace(template, "@RETURN_TO@", url.QueryEscape(authURL), 1) // If now there is no more ORG_ID, return as there weren't enough @ symbols - if !strings.Contains(authTplt, "@ORG_ID@") { + if !strings.Contains(template, "@ORG_ID@") { return authURL } // Replace ORG ID - authTplt = strings.Replace(authTplt, "@ORG_ID@", url.QueryEscape(orgID), 1) - return authTplt + template = strings.Replace(template, "@ORG_ID@", url.QueryEscape(orgID), 1) + return template } // GetLanguageMatched uses a map from language tags to strings to extract the right language given the tag |
