mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
[MM-37772] Idiomatic naming (URL, URI, API) (#18128)
* s/Url/URL/g & s/Uri/URI/g * s/Api/API/g
This commit is contained in:
@@ -44,14 +44,14 @@ func newRandomBase32String(size int) string {
|
||||
return base32.StdEncoding.EncodeToString(data)
|
||||
}
|
||||
|
||||
func getIssuerFromUrl(uri string) string {
|
||||
func getIssuerFromURL(uri string) string {
|
||||
issuer := "Mattermost"
|
||||
siteUrl := strings.TrimSpace(uri)
|
||||
siteURL := strings.TrimSpace(uri)
|
||||
|
||||
if siteUrl != "" {
|
||||
siteUrl = strings.TrimPrefix(siteUrl, "https://")
|
||||
siteUrl = strings.TrimPrefix(siteUrl, "http://")
|
||||
issuer = strings.TrimPrefix(siteUrl, "www.")
|
||||
if siteURL != "" {
|
||||
siteURL = strings.TrimPrefix(siteURL, "https://")
|
||||
siteURL = strings.TrimPrefix(siteURL, "http://")
|
||||
issuer = strings.TrimPrefix(siteURL, "www.")
|
||||
}
|
||||
|
||||
return url.QueryEscape(issuer)
|
||||
@@ -59,7 +59,7 @@ func getIssuerFromUrl(uri string) string {
|
||||
|
||||
// GenerateSecret generates a new user mfa secret and store it with the StoreSecret function provided
|
||||
func (m *MFA) GenerateSecret(siteURL, userEmail, userID string) (string, []byte, error) {
|
||||
issuer := getIssuerFromUrl(siteURL)
|
||||
issuer := getIssuerFromURL(siteURL)
|
||||
|
||||
secret := newRandomBase32String(mfaSecretSize)
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ func TestGenerateSecret(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestGetIssuerFromUrl(t *testing.T) {
|
||||
func TestGetIssuerFromURL(t *testing.T) {
|
||||
cases := []struct {
|
||||
Input string
|
||||
Expected string
|
||||
@@ -64,7 +64,7 @@ func TestGetIssuerFromUrl(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
assert.Equal(t, c.Expected, getIssuerFromUrl(c.Input))
|
||||
assert.Equal(t, c.Expected, getIssuerFromURL(c.Input))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user