@onekeyfe/react-native-network-throttle 3.0.82-alpha.0 → 3.0.83-alpha.0
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/README.md
CHANGED
|
@@ -11,4 +11,10 @@ lifetime of the native process. This allows independently initialized React
|
|
|
11
11
|
Native runtimes to register local development servers without clearing each
|
|
12
12
|
other's configuration.
|
|
13
13
|
|
|
14
|
+
Known limitation: on Android the bypass decision is made once per logical
|
|
15
|
+
request (OkHttp application interceptor), so a cross-origin redirect keeps the
|
|
16
|
+
initial request's bypass decision; iOS re-evaluates each request. Exact-origin
|
|
17
|
+
bypasses target local development servers, which do not redirect across
|
|
18
|
+
origins.
|
|
19
|
+
|
|
14
20
|
This package only owns native request throttling. Product settings, persistence, and UI controls should remain in the host app.
|
|
@@ -144,8 +144,15 @@ internal object NetworkThrottle {
|
|
|
144
144
|
private fun normalizeOrigin(value: String?): String? =
|
|
145
145
|
value?.toHttpUrlOrNull()?.let(::canonicalOrigin)
|
|
146
146
|
|
|
147
|
-
private fun shouldBypass(requestUrl: HttpUrl): Boolean
|
|
148
|
-
|
|
147
|
+
private fun shouldBypass(requestUrl: HttpUrl): Boolean {
|
|
148
|
+
// The interceptor is installed in every build; skip the per-request
|
|
149
|
+
// canonicalization allocation while no origin is registered.
|
|
150
|
+
val origins = bypassUrlOrigins.get()
|
|
151
|
+
if (origins.isEmpty()) {
|
|
152
|
+
return false
|
|
153
|
+
}
|
|
154
|
+
return origins.contains(canonicalOrigin(requestUrl))
|
|
155
|
+
}
|
|
149
156
|
|
|
150
157
|
private fun sleepNanos(delayNanos: Long) {
|
|
151
158
|
if (delayNanos <= 0) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/react-native-network-throttle",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.83-alpha.0",
|
|
4
4
|
"description": "react-native-network-throttle",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/src/index.d.ts",
|
|
@@ -142,6 +142,5 @@
|
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
|
-
}
|
|
146
|
-
"stableVersion": "3.0.81"
|
|
145
|
+
}
|
|
147
146
|
}
|