@loopaware/react-native 0.1.0 → 0.7.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +13 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
import React, { createContext, useContext, useMemo, useState } from "react";
|
|
2
2
|
import { Modal, Platform, Pressable, StyleSheet, Text, TextInput, View, } from "react-native";
|
|
3
3
|
const LoopAwareContext = createContext(null);
|
|
4
|
+
const maximumAPIOriginLength = 2048;
|
|
5
|
+
function withoutTrailingSlashes(value) {
|
|
6
|
+
if (value.length > maximumAPIOriginLength) {
|
|
7
|
+
throw new Error("loopaware_api_origin_too_long");
|
|
8
|
+
}
|
|
9
|
+
let end = value.length;
|
|
10
|
+
while (end > 0 && value.charCodeAt(end - 1) === 47) {
|
|
11
|
+
end -= 1;
|
|
12
|
+
}
|
|
13
|
+
return value.slice(0, end);
|
|
14
|
+
}
|
|
4
15
|
export function LoopAwareProvider({ children, siteId, mobileClientId, apiOrigin, app, defaultContext, }) {
|
|
5
16
|
const value = useMemo(() => ({
|
|
6
17
|
siteId,
|
|
7
18
|
mobileClientId,
|
|
8
|
-
apiOrigin: apiOrigin
|
|
19
|
+
apiOrigin: withoutTrailingSlashes(apiOrigin),
|
|
9
20
|
app,
|
|
10
21
|
defaultContext,
|
|
11
22
|
}), [siteId, mobileClientId, apiOrigin, app, defaultContext]);
|
|
@@ -24,7 +35,7 @@ export async function submitLoopAwareFeedback(config, input) {
|
|
|
24
35
|
...(input.context ?? {}),
|
|
25
36
|
};
|
|
26
37
|
const platform = config.app.platform ?? (Platform.OS === "ios" || Platform.OS === "android" ? Platform.OS : "ios");
|
|
27
|
-
const response = await fetch(`${config.apiOrigin
|
|
38
|
+
const response = await fetch(`${withoutTrailingSlashes(config.apiOrigin)}/public/mobile-feedback`, {
|
|
28
39
|
method: "POST",
|
|
29
40
|
headers: { "Content-Type": "application/json" },
|
|
30
41
|
body: JSON.stringify({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loopaware/react-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.53",
|
|
4
4
|
"description": "React Native feedback widget client for LoopAware.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"type": "module",
|
|
@@ -45,6 +45,6 @@
|
|
|
45
45
|
"react-native": ">=0.72.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"typescript": "^
|
|
48
|
+
"typescript": "^7.0.2"
|
|
49
49
|
}
|
|
50
50
|
}
|