File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed
main/java/com/segment/analytics/android/integrations/firebase
test/java/com/segment/analytics/android/integration/firebase Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -213,13 +213,13 @@ && isNullOrEmpty(properties.currency())) {
213213 }
214214
215215 public static String makeKey (String key ) {
216- if (key .contains ("." )) {
217- key = key .trim ().replace ("." , "_" );
218- } else if (key .contains ("-" )) {
219- key = key .trim ().replace ("-" , "_" );
220- } else {
221- key = key .trim ().replaceAll (" " , "_" );
216+ String [] forbiddenChars = {"." , "-" , " " };
217+ for (String forbidden : forbiddenChars ) {
218+ if (key .contains (forbidden )) {
219+ key = key .trim ().replace (forbidden , "_" );
220+ }
222221 }
222+
223223 return key .substring (0 , Math .min (key .length (), 40 ));
224224 }
225225}
Original file line number Diff line number Diff line change @@ -169,6 +169,12 @@ public void makeKeyWithDot() {
169169 verify (firebase ).logEvent (eq ("test_event" ), bundleEq (new Bundle ()));
170170 }
171171
172+ @ Test
173+ public void makeKeyWithDashAndDot () {
174+ integration .track (new TrackPayload .Builder ().anonymousId ("12345" ).event ("test-event-dashed-and.dotted" ).build ());
175+ verify (firebase ).logEvent (eq ("test_event_dashed_and_dotted" ), bundleEq (new Bundle ()));
176+ }
177+
172178 /**
173179 * Uses the string representation of the object. Useful for JSON objects.
174180 * @param expected Expected object
You can’t perform that action at this time.
0 commit comments