Skip to content

Commit 7988a3d

Browse files
author
Niall Brennan
committed
logic for dot and dash
1 parent 0063b9a commit 7988a3d

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/main/java/com/segment/analytics/android/integrations/firebase/FirebaseIntegration.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff 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
}

src/test/java/com/segment/analytics/android/integration/firebase/FirebaseTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)