Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nginx-push-stream-module
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
nginx-push-stream-module
Commits
49f62ed2
Commit
49f62ed2
authored
Jul 17, 2012
by
geocraft
Committed by
Wandenberg Peixoto
Nov 13, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Theres no point in unescaping data that is not string
parent
8a5c4f85
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
1 deletion
+35
-1
pushstream.js
misc/js/pushstream.js
+1
-1
PushStreamUtilsSpec.js
test/spec/javascripts/PushStreamUtilsSpec.js
+34
-0
No files found.
misc/js/pushstream.js
View file @
49f62ed2
...
@@ -305,7 +305,7 @@
...
@@ -305,7 +305,7 @@
var
message
=
{
var
message
=
{
id
:
msg
[
keys
.
jsonIdKey
],
id
:
msg
[
keys
.
jsonIdKey
],
channel
:
msg
[
keys
.
jsonChannelKey
],
channel
:
msg
[
keys
.
jsonChannelKey
],
data
:
unescapeText
(
msg
[
keys
.
jsonDataKey
]),
data
:
(
typeof
(
msg
[
keys
.
jsonDataKey
])
==
'
string
'
)
?
unescapeText
(
msg
[
keys
.
jsonDataKey
])
:
msg
[
keys
.
jsonDataKey
],
tag
:
msg
[
keys
.
jsonTagKey
],
tag
:
msg
[
keys
.
jsonTagKey
],
time
:
msg
[
keys
.
jsonTimeKey
],
time
:
msg
[
keys
.
jsonTimeKey
],
eventid
:
msg
[
keys
.
jsonEventIdKey
]
||
""
eventid
:
msg
[
keys
.
jsonEventIdKey
]
||
""
...
...
test/spec/javascripts/PushStreamUtilsSpec.js
0 → 100644
View file @
49f62ed2
describe
(
"
PushStreamUtils
"
,
function
()
{
var
jsonKeys
=
{
jsonIdKey
:
'
id
'
,
jsonChannelKey
:
'
channel
'
,
jsonDataKey
:
'
text
'
,
jsonTagKey
:
'
tag
'
,
jsonTimeKey
:
'
time
'
,
jsonEventIdKey
:
'
eventid
'
};
beforeEach
(
function
()
{
});
describe
(
"
when parsing a message
"
,
function
()
{
it
(
"
should accept a simple string as text
"
,
function
()
{
var
message
=
parseMessage
(
'
{"id":31,"channel":"54x19","text":"some simple string"}
'
,
jsonKeys
);
expect
(
message
.
data
).
toBe
(
"
some simple string
"
);
});
it
(
"
should accept a json as text
"
,
function
()
{
var
message
=
parseMessage
(
'
{"id":31,"channel":"54x19","text":{"id":"500516b7639e4029b8000001","type":"Player","change":{"loc":[54.34772390000001,18.5610535],"version":7}}}
'
,
jsonKeys
);
expect
(
message
.
data
.
id
).
toBe
(
"
500516b7639e4029b8000001
"
);
expect
(
message
.
data
.
type
).
toBe
(
"
Player
"
);
expect
(
message
.
data
.
change
.
loc
[
0
]).
toBe
(
54.34772390000001
);
expect
(
message
.
data
.
change
.
loc
[
1
]).
toBe
(
18.5610535
);
expect
(
message
.
data
.
change
.
version
).
toBe
(
7
);
});
it
(
"
should accept an escaped json as text
"
,
function
()
{
var
message
=
parseMessage
(
'
{"id":31,"channel":"54x19","text":"%7B%22id%22%3A%22500516b7639e4029b8000001%22%2C%22type%22%3A%22Player%22%2C%22change%22%3A%7B%22loc%22%3A%5B54.34772390000001%2C18.5610535%5D%2C%22version%22%3A7%7D%7D"}
'
,
jsonKeys
);
expect
(
message
.
data
).
toBe
(
'
{"id":"500516b7639e4029b8000001","type":"Player","change":{"loc":[54.34772390000001,18.5610535],"version":7}}
'
);
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment