2019-11-29 12:59:40 +01:00
|
|
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
|
|
|
// See LICENSE.txt for license information.
|
2017-01-25 15:00:06 +01:00
|
|
|
|
|
|
|
|
package utils
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"testing"
|
2019-11-12 21:15:32 +07:00
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
2017-01-25 15:00:06 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestUrlEncode(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
toEncode := "testing 1 2 3"
|
|
|
|
|
encoded := UrlEncode(toEncode)
|
|
|
|
|
|
2019-11-12 21:15:32 +07:00
|
|
|
require.Equal(t, encoded, "testing%201%202%203")
|
2017-01-25 15:00:06 +01:00
|
|
|
|
|
|
|
|
toEncode = "testing123"
|
|
|
|
|
encoded = UrlEncode(toEncode)
|
|
|
|
|
|
2019-11-12 21:15:32 +07:00
|
|
|
require.Equal(t, encoded, "testing123")
|
2017-01-25 15:00:06 +01:00
|
|
|
|
|
|
|
|
toEncode = "testing$#~123"
|
|
|
|
|
encoded = UrlEncode(toEncode)
|
|
|
|
|
|
2019-11-12 21:15:32 +07:00
|
|
|
require.Equal(t, encoded, "testing%24%23~123")
|
2017-01-25 15:00:06 +01:00
|
|
|
}
|