expo-router 2.0.13 → 2.0.14
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/build/utils/url.d.ts +2 -0
- package/build/utils/url.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/global-state/routing.ts +2 -2
- package/src/utils/url.ts +16 -0
package/build/utils/url.d.ts
CHANGED
|
@@ -3,4 +3,6 @@
|
|
|
3
3
|
* NOTE: Additional strictness added to ensure URLs sent in query parameters for in-app navigation are not matched.
|
|
4
4
|
*/
|
|
5
5
|
export declare function hasUrlProtocolPrefix(href: string): boolean;
|
|
6
|
+
export declare function isWellKnownUri(href: string): boolean;
|
|
7
|
+
export declare function shouldLinkExternally(href: string): boolean;
|
|
6
8
|
//# sourceMappingURL=url.d.ts.map
|
package/build/utils/url.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../src/utils/url.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE1D"}
|
|
1
|
+
{"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../src/utils/url.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAOpD;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAK1D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-router",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.14",
|
|
4
4
|
"main": "src/index.tsx",
|
|
5
5
|
"types": "build/index.d.ts",
|
|
6
6
|
"license": "MIT",
|
|
@@ -106,12 +106,12 @@
|
|
|
106
106
|
},
|
|
107
107
|
"dependencies": {
|
|
108
108
|
"@bacons/react-views": "^1.1.3",
|
|
109
|
-
"@expo/metro-runtime": "2.2.
|
|
109
|
+
"@expo/metro-runtime": "2.2.16",
|
|
110
110
|
"@radix-ui/react-slot": "1.0.1",
|
|
111
111
|
"@react-navigation/bottom-tabs": "~6.5.7",
|
|
112
112
|
"@react-navigation/native": "~6.1.6",
|
|
113
113
|
"@react-navigation/native-stack": "~6.9.12",
|
|
114
|
-
"expo-head": "0.0.
|
|
114
|
+
"expo-head": "0.0.20",
|
|
115
115
|
"expo-splash-screen": "~0.20.2",
|
|
116
116
|
"query-string": "7.1.3",
|
|
117
117
|
"react-helmet-async": "^1.3.0",
|
|
@@ -7,7 +7,7 @@ import * as Linking from "expo-linking";
|
|
|
7
7
|
import { ResultState } from "../fork/getStateFromPath";
|
|
8
8
|
import { Href, resolveHref } from "../link/href";
|
|
9
9
|
import { resolve } from "../link/path";
|
|
10
|
-
import {
|
|
10
|
+
import { shouldLinkExternally } from "../utils/url";
|
|
11
11
|
import type { RouterStore } from "./router-store";
|
|
12
12
|
|
|
13
13
|
function assertIsReady(store: RouterStore) {
|
|
@@ -52,7 +52,7 @@ export function setParams(
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
export function linkTo(this: RouterStore, href: string, event?: string) {
|
|
55
|
-
if (
|
|
55
|
+
if (shouldLinkExternally(href)) {
|
|
56
56
|
Linking.openURL(href);
|
|
57
57
|
return;
|
|
58
58
|
}
|
package/src/utils/url.ts
CHANGED
|
@@ -5,3 +5,19 @@
|
|
|
5
5
|
export function hasUrlProtocolPrefix(href: string): boolean {
|
|
6
6
|
return /^[\w\d_+.-]+:\/\//.test(href);
|
|
7
7
|
}
|
|
8
|
+
|
|
9
|
+
export function isWellKnownUri(href: string): boolean {
|
|
10
|
+
// This is a hack and we should change this to work like the web in the future where we have full confidence in the
|
|
11
|
+
// ability to match URLs and send anything unmatched to the OS. The main difference between this and `hasUrlProtocolPrefix` is
|
|
12
|
+
// that we don't require `//`, e.g. `mailto:` is valid and common, and `mailto://bacon` is invalid.
|
|
13
|
+
return /^(https?|mailto|tel|sms|geo|maps|market|itmss?|itms-apps|content|file):/.test(
|
|
14
|
+
href
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function shouldLinkExternally(href: string): boolean {
|
|
19
|
+
// Cheap check first to avoid regex if the href is not a path fragment.
|
|
20
|
+
return (
|
|
21
|
+
!/^[./]/.test(href) && (hasUrlProtocolPrefix(href) || isWellKnownUri(href))
|
|
22
|
+
);
|
|
23
|
+
}
|