Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit 13de07e

Browse files
Compatibility with older JS versions
1 parent 8fffc8f commit 13de07e

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

src/analytics/analytics-common.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { LogEventParameter } from "./analytics";
22

33
export function validateAnalyticsKey(key: string): string | undefined {
4-
if (key === undefined) {
4+
if (key === undefined || key === null) {
55
return "Argument 'key' is missing";
66
}
77

@@ -13,15 +13,15 @@ export function validateAnalyticsKey(key: string): string | undefined {
1313
return "Argument 'key' can only contain alphanumeric characters and underscores and must start with an alphanumeric character";
1414
}
1515

16-
if (key.startsWith("firebase_")) {
16+
if (key.indexOf("firebase_") === 0) {
1717
return "Argument 'key' must not start with 'firebase_'";
1818
}
1919

20-
if (key.startsWith("google_")) {
20+
if (key.indexOf("google_") === 0) {
2121
return "Argument 'key' must not start with 'google_'";
2222
}
2323

24-
if (key.startsWith("ga_")) {
24+
if (key.indexOf("ga_") === 0) {
2525
return "Argument 'key' must not start with 'ga_'";
2626
}
2727

@@ -75,23 +75,23 @@ function validateAnalyticsParamKey(key: string): string | undefined {
7575
}
7676

7777
function validateAnalyticsParamValue(value: string): string | undefined {
78-
if (value === undefined) {
78+
if (value === undefined || value === null) {
7979
return "Param 'value' is missing";
8080
}
8181

8282
if (value.length > 100) {
8383
return "Param 'value' must be 100 characters or fewer";
8484
}
8585

86-
if (value.startsWith("firebase_")) {
86+
if (value.indexOf("firebase_") === 0) {
8787
return "Param 'value' must not start with 'firebase_'";
8888
}
8989

90-
if (value.startsWith("google_")) {
90+
if (value.indexOf("google_") === 0) {
9191
return "Param 'value' must not start with 'google_'";
9292
}
9393

94-
if (value.startsWith("ga_")) {
94+
if (value.indexOf("ga_") === 0) {
9595
return "Param 'value' must not start with 'ga_'";
9696
}
9797

src/mlkit/custommodel/custommodel-common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export abstract class MLKitCustomModel extends MLKitCameraView {
4848

4949
[labelsFileProperty.setNative](value: string) {
5050
this.labelsFile = value;
51-
if (value.startsWith("~/")) {
51+
if (value.indexOf("~/") === 0) {
5252
this.labels = getLabelsFromAppFolder(value);
5353
} else {
5454
// no dice loading from assets yet, let's advice users to use ~/ for now

src/mlkit/custommodel/index.android.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ function getInterpreter(localModelFile?: string): any {
108108
} else {
109109
const firModelLocalBuilder = new com.google.firebase.ml.common.modeldownload.FirebaseLocalModel.Builder(localModelName);
110110

111-
if (localModelFile.startsWith("~/")) {
111+
if (localModelFile.indexOf("~/") === 0) {
112112
firModelLocalBuilder.setFilePath(fs.knownFolders.currentApp().path + localModelFile.substring(1));
113113
} else {
114114
// note that this doesn't seem to work, let's advice users to use ~/ for now
@@ -143,7 +143,7 @@ export function useCustomModel(options: MLKitCustomModelOptions): Promise<MLKitC
143143
const interpreter = getInterpreter(options.localModelFile);
144144

145145
let labels: Array<string>;
146-
if (options.labelsFile.startsWith("~/")) {
146+
if (options.labelsFile.indexOf("~/") === 0) {
147147
labels = getLabelsFromAppFolder(options.labelsFile);
148148
} else {
149149
// no dice loading from assets yet, let's advice users to use ~/ for now

src/mlkit/custommodel/index.ios.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ function getInterpreter(localModelFile: string): FIRModelInterpreter {
113113
localModelRegistrationSuccess = true;
114114
} else {
115115
let localModelFilePath: string;
116-
if (localModelFile.startsWith("~/")) {
116+
if (localModelFile.indexOf("~/") === 0) {
117117
localModelFilePath = fs.knownFolders.currentApp().path + localModelFile.substring(1);
118118
} else {
119119
localModelFilePath = NSBundle.mainBundle.pathForResourceOfType(
@@ -184,7 +184,7 @@ export function useCustomModel(options: MLKitCustomModelOptions): Promise<MLKitC
184184
});
185185

186186
let labels: Array<string>;
187-
if (options.labelsFile.startsWith("~/")) {
187+
if (options.labelsFile.indexOf("~/") === 0) {
188188
labels = getLabelsFromAppFolder(options.labelsFile);
189189
} else {
190190
const labelsFile = NSBundle.mainBundle.pathForResourceOfType(

0 commit comments

Comments
 (0)