summaryrefslogtreecommitdiffstats
path: root/utils/urlencode_test.go
blob: 2ba453c73a46307d13790da70a7da1859e9aa0ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

package utils

import (
	"testing"
)

func TestUrlEncode(t *testing.T) {

	toEncode := "testing 1 2 3"
	encoded := UrlEncode(toEncode)

	if encoded != "testing%201%202%203" {
		t.Log(encoded)
		t.Fatal("should be equal")
	}

	toEncode = "testing123"
	encoded = UrlEncode(toEncode)

	if encoded != "testing123" {
		t.Log(encoded)
		t.Fatal("should be equal")
	}

	toEncode = "testing$#~123"
	encoded = UrlEncode(toEncode)

	if encoded != "testing%24%23~123" {
		t.Log(encoded)
		t.Fatal("should be equal")
	}
}