Skip to content

Commit 1fc5ae6

Browse files
committed
Merge pull request #13 from coshx/fix/strings_starting_with_number
Fixes string casting
2 parents f0bf1d3 + b3d0c59 commit 1fc5ae6

File tree

7 files changed

+28
-9
lines changed

7 files changed

+28
-9
lines changed

Caravel.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Pod::Spec.new do |s|
1515
# summary should be tweet-length, and the description more in depth.
1616
#
1717

18-
version = "0.4.2"
18+
version = "0.4.3"
1919

2020
s.name = "Caravel"
2121
s.version = version

caravel-test/EventDataController.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,16 @@ public class EventDataController: UIViewController {
7373
}
7474
}
7575

76+
bus.register("UUID") { name, data in
77+
if let s = data as? String {
78+
if s != "9658ae60-9e0d-4da7-a63d-46fe75ff1db1" {
79+
self._raise("UUID - bad value")
80+
}
81+
} else {
82+
self._raise("UUID - bad type")
83+
}
84+
}
85+
7686
bus.register("Array") { name, data in
7787
if let a = data as? NSArray {
7888
if a.count != 3 {

caravel-test/js/event_data.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ Caravel.getDefault().post("Int", 987);
119119
Caravel.getDefault().post("Float", 19.89);
120120
Caravel.getDefault().post("Double", 15.15);
121121
Caravel.getDefault().post("String", "Napoleon");
122+
Caravel.getDefault().post("UUID", "9658ae60-9e0d-4da7-a63d-46fe75ff1db1");
122123
Caravel.getDefault().post("Array", [3, 1, 4]);
123124
Caravel.getDefault().post("Dictionary", { "movie": "Once upon a time in the West", "actor": "Charles Bronson" });
124125

caravel/ArgumentParser.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ internal class ArgumentParser {
2121
for p in queryPairs {
2222
var keyValue = p.componentsSeparatedByString("=")
2323
if keyValue[0] == "busName" {
24-
outcome.busName = keyValue[1].stringByReplacingPercentEscapesUsingEncoding(NSUTF8StringEncoding)!
24+
outcome.busName = keyValue[1].stringByRemovingPercentEncoding!
2525
} else if keyValue[0] == "eventName" {
26-
outcome.eventName = keyValue[1].stringByReplacingPercentEscapesUsingEncoding(NSUTF8StringEncoding)!
26+
outcome.eventName = keyValue[1].stringByRemovingPercentEncoding!
2727
} else if keyValue[0] == "eventData" {
28-
outcome.eventData = keyValue[1].stringByReplacingPercentEscapesUsingEncoding(NSUTF8StringEncoding)
28+
outcome.eventData = keyValue[1].stringByRemovingPercentEncoding
2929
}
3030
}
3131

caravel/DataSerializer.swift

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,17 @@ internal class DataSerializer {
5454
return try! NSJSONSerialization.JSONObjectWithData(json, options: NSJSONReadingOptions())
5555
}
5656

57-
// To investigate if the input is a number (int or double),
58-
// we check if the first char is a digit or no
59-
if let _ = Int(input[0]) {
57+
var isNumber = true
58+
for i in 0..<input.characters.count {
59+
if Int(input[i]) != nil || input[i] == "." || input[i] == "," {
60+
// Do nothing
61+
} else {
62+
isNumber = false
63+
break
64+
}
65+
}
66+
67+
if isNumber {
6068
if let i = Int(input) {
6169
return i
6270
} else {

caravel/js/Gruntfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = function (grunt) {
22
'use strict';
33

4-
var version = '0.4.2';
4+
var version = '0.4.3';
55

66
// Project configuration
77
grunt.initConfig({

caravel/js/caravel.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)