summaryrefslogtreecommitdiffstats
path: root/utils/urlencode.go
diff options
context:
space:
mode:
authorJoramWilander <jwawilander@gmail.com>2015-07-17 15:55:06 -0400
committerJoramWilander <jwawilander@gmail.com>2015-07-21 19:22:04 -0400
commitc63fbd4ccc5e7a11c4ce15fe7d19a3daf4e5c45e (patch)
tree86c79a43ded7407c2c9b955072f225762721b2d0 /utils/urlencode.go
parentedf26b4bc6f997d3dc2927b24e5787e6f66f2eb6 (diff)
downloadchat-c63fbd4ccc5e7a11c4ce15fe7d19a3daf4e5c45e.tar.gz
chat-c63fbd4ccc5e7a11c4ce15fe7d19a3daf4e5c45e.tar.bz2
chat-c63fbd4ccc5e7a11c4ce15fe7d19a3daf4e5c45e.zip
add proper url encoding for filenames
Diffstat (limited to 'utils/urlencode.go')
-rw-r--r--utils/urlencode.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/utils/urlencode.go b/utils/urlencode.go
new file mode 100644
index 000000000..63a8f7880
--- /dev/null
+++ b/utils/urlencode.go
@@ -0,0 +1,19 @@
+// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+package utils
+
+import (
+ "net/url"
+ "strings"
+)
+
+func UrlEncode(str string) string {
+ strs := strings.Split(str, " ")
+
+ for i, s := range strs {
+ strs[i] = url.QueryEscape(s)
+ }
+
+ return strings.Join(strs, "%20")
+}