mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-01-13 09:30:30 +08:00
Compare commits
8 Commits
@react-nav
...
@react-nav
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
860adbfd8b | ||
|
|
38d680833e | ||
|
|
cae115fc17 | ||
|
|
87b51476d0 | ||
|
|
b1b211855f | ||
|
|
60fe0dbb0a | ||
|
|
bb294b16f9 | ||
|
|
4ca2d2d22b |
@@ -3,6 +3,36 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [5.11.7](https://github.com/react-navigation/react-navigation/compare/@react-navigation/bottom-tabs@5.11.6...@react-navigation/bottom-tabs@5.11.7) (2021-01-25)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* fix drawer screen content not being interactable on Android ([87b5147](https://github.com/react-navigation/react-navigation/commit/87b51476d0bce8f2dae793416c2976da30a1a5f7))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [5.11.6](https://github.com/react-navigation/react-navigation/compare/@react-navigation/bottom-tabs@5.11.5...@react-navigation/bottom-tabs@5.11.6) (2021-01-22)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* fix pointerEvents in ResourceSavingScene ([60fe0db](https://github.com/react-navigation/react-navigation/commit/60fe0dbb0ae443fdb21016d368c919b933cb64e7)), closes [#9241](https://github.com/react-navigation/react-navigation/issues/9241) [#9242](https://github.com/react-navigation/react-navigation/issues/9242)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [5.11.5](https://github.com/react-navigation/react-navigation/compare/@react-navigation/bottom-tabs@5.11.4...@react-navigation/bottom-tabs@5.11.5) (2021-01-22)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/bottom-tabs
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [5.11.4](https://github.com/react-navigation/react-navigation/compare/@react-navigation/bottom-tabs@5.11.3...@react-navigation/bottom-tabs@5.11.4) (2021-01-21)
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@react-navigation/bottom-tabs",
|
||||
"description": "Bottom tab navigator following iOS design guidelines",
|
||||
"version": "5.11.4",
|
||||
"version": "5.11.7",
|
||||
"keywords": [
|
||||
"react-native-component",
|
||||
"react-component",
|
||||
@@ -40,7 +40,7 @@
|
||||
"react-native-iphone-x-helper": "^1.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@react-navigation/native": "^5.9.1",
|
||||
"@react-navigation/native": "^5.9.2",
|
||||
"@testing-library/react-native": "^7.1.0",
|
||||
"@types/color": "^3.0.1",
|
||||
"@types/react": "^16.9.53",
|
||||
|
||||
@@ -60,7 +60,11 @@ export default function ResourceSavingScene({
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={[styles.container, style]}>
|
||||
<View
|
||||
style={[styles.container, style]}
|
||||
// box-none doesn't seem to work properly on Android
|
||||
pointerEvents={isVisible ? 'auto' : 'none'}
|
||||
>
|
||||
<View
|
||||
collapsable={false}
|
||||
removeClippedSubviews={
|
||||
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [5.3.13](https://github.com/react-navigation/react-navigation/compare/@react-navigation/compat@5.3.12...@react-navigation/compat@5.3.13) (2021-01-22)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/compat
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [5.3.12](https://github.com/react-navigation/react-navigation/compare/@react-navigation/compat@5.3.11...@react-navigation/compat@5.3.12) (2021-01-21)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/compat
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@react-navigation/compat",
|
||||
"description": "Compatibility layer to write navigator definitions in static configuration format",
|
||||
"version": "5.3.12",
|
||||
"version": "5.3.13",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -31,7 +31,7 @@
|
||||
"clean": "del lib"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@react-navigation/native": "^5.9.1",
|
||||
"@react-navigation/native": "^5.9.2",
|
||||
"@types/react": "^16.9.53",
|
||||
"react": "~16.13.1",
|
||||
"react-native-builder-bob": "^0.17.0",
|
||||
|
||||
@@ -3,6 +3,36 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [5.12.3](https://github.com/react-navigation/react-navigation/compare/@react-navigation/drawer@5.12.2...@react-navigation/drawer@5.12.3) (2021-01-25)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* fix drawer screen content not being interactable on Android ([87b5147](https://github.com/react-navigation/react-navigation/commit/87b51476d0bce8f2dae793416c2976da30a1a5f7))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [5.12.2](https://github.com/react-navigation/react-navigation/compare/@react-navigation/drawer@5.12.1...@react-navigation/drawer@5.12.2) (2021-01-22)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* fix pointerEvents in ResourceSavingScene ([60fe0db](https://github.com/react-navigation/react-navigation/commit/60fe0dbb0ae443fdb21016d368c919b933cb64e7)), closes [#9241](https://github.com/react-navigation/react-navigation/issues/9241) [#9242](https://github.com/react-navigation/react-navigation/issues/9242)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [5.12.1](https://github.com/react-navigation/react-navigation/compare/@react-navigation/drawer@5.12.0...@react-navigation/drawer@5.12.1) (2021-01-22)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/drawer
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# [5.12.0](https://github.com/react-navigation/react-navigation/compare/@react-navigation/drawer@5.11.5...@react-navigation/drawer@5.12.0) (2021-01-21)
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@react-navigation/drawer",
|
||||
"description": "Drawer navigator component with animated transitions and gesturess",
|
||||
"version": "5.12.0",
|
||||
"version": "5.12.3",
|
||||
"keywords": [
|
||||
"react-native-component",
|
||||
"react-component",
|
||||
@@ -45,7 +45,7 @@
|
||||
"react-native-iphone-x-helper": "^1.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@react-navigation/native": "^5.9.1",
|
||||
"@react-navigation/native": "^5.9.2",
|
||||
"@testing-library/react-native": "^7.1.0",
|
||||
"@types/react": "^16.9.53",
|
||||
"@types/react-native": "^0.63.30",
|
||||
|
||||
@@ -60,7 +60,11 @@ export default function ResourceSavingScene({
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={[styles.container, style]}>
|
||||
<View
|
||||
style={[styles.container, style]}
|
||||
// box-none doesn't seem to work properly on Android
|
||||
pointerEvents={isVisible ? 'auto' : 'none'}
|
||||
>
|
||||
<View
|
||||
collapsable={false}
|
||||
removeClippedSubviews={
|
||||
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [5.3.13](https://github.com/react-navigation/react-navigation/compare/@react-navigation/material-bottom-tabs@5.3.12...@react-navigation/material-bottom-tabs@5.3.13) (2021-01-22)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/material-bottom-tabs
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [5.3.12](https://github.com/react-navigation/react-navigation/compare/@react-navigation/material-bottom-tabs@5.3.11...@react-navigation/material-bottom-tabs@5.3.12) (2021-01-21)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/material-bottom-tabs
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@react-navigation/material-bottom-tabs",
|
||||
"description": "Integration for bottom navigation component from react-native-paper",
|
||||
"version": "5.3.12",
|
||||
"version": "5.3.13",
|
||||
"keywords": [
|
||||
"react-native-component",
|
||||
"react-component",
|
||||
@@ -41,7 +41,7 @@
|
||||
"clean": "del lib"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@react-navigation/native": "^5.9.1",
|
||||
"@react-navigation/native": "^5.9.2",
|
||||
"@testing-library/react-native": "^7.1.0",
|
||||
"@types/react": "^16.9.53",
|
||||
"@types/react-native": "^0.63.30",
|
||||
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [5.3.13](https://github.com/react-navigation/react-navigation/compare/@react-navigation/material-top-tabs@5.3.12...@react-navigation/material-top-tabs@5.3.13) (2021-01-22)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/material-top-tabs
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [5.3.12](https://github.com/react-navigation/react-navigation/compare/@react-navigation/material-top-tabs@5.3.11...@react-navigation/material-top-tabs@5.3.12) (2021-01-21)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/material-top-tabs
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@react-navigation/material-top-tabs",
|
||||
"description": "Integration for the animated tab view component from react-native-tab-view",
|
||||
"version": "5.3.12",
|
||||
"version": "5.3.13",
|
||||
"keywords": [
|
||||
"react-native-component",
|
||||
"react-component",
|
||||
@@ -44,7 +44,7 @@
|
||||
"color": "^3.1.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@react-navigation/native": "^5.9.1",
|
||||
"@react-navigation/native": "^5.9.2",
|
||||
"@testing-library/react-native": "^7.1.0",
|
||||
"@types/react": "^16.9.53",
|
||||
"@types/react-native": "^0.63.30",
|
||||
|
||||
@@ -3,6 +3,17 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [5.9.2](https://github.com/react-navigation/react-navigation/compare/@react-navigation/native@5.9.1...@react-navigation/native@5.9.2) (2021-01-22)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* normalize prefix when parsing. fixes [#9081](https://github.com/react-navigation/react-navigation/issues/9081) ([4ca2d2d](https://github.com/react-navigation/react-navigation/commit/4ca2d2d22bc9eccf87451b15c823174d98cbd0a2))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [5.9.1](https://github.com/react-navigation/react-navigation/compare/@react-navigation/native@5.9.0...@react-navigation/native@5.9.1) (2021-01-21)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/native
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@react-navigation/native",
|
||||
"description": "React Native integration for React Navigation",
|
||||
"version": "5.9.1",
|
||||
"version": "5.9.2",
|
||||
"keywords": [
|
||||
"react-native",
|
||||
"react-navigation",
|
||||
|
||||
318
packages/native/src/__tests__/extractPathFromURL.test.tsx
Normal file
318
packages/native/src/__tests__/extractPathFromURL.test.tsx
Normal file
@@ -0,0 +1,318 @@
|
||||
import extractPathFromURL from '../extractPathFromURL';
|
||||
|
||||
it('extracts path from URL with protocol', () => {
|
||||
expect(extractPathFromURL(['scheme://'], 'scheme://some/path')).toBe(
|
||||
'some/path'
|
||||
);
|
||||
|
||||
expect(extractPathFromURL(['scheme://'], 'scheme:some/path')).toBe(
|
||||
'some/path'
|
||||
);
|
||||
|
||||
expect(extractPathFromURL(['scheme://'], 'scheme:///some/path')).toBe(
|
||||
'some/path'
|
||||
);
|
||||
|
||||
expect(extractPathFromURL(['scheme:///'], 'scheme:some/path')).toBe(
|
||||
'some/path'
|
||||
);
|
||||
|
||||
expect(extractPathFromURL(['scheme:'], 'scheme:some/path')).toBe('some/path');
|
||||
|
||||
expect(extractPathFromURL(['scheme:'], 'scheme://some/path')).toBe(
|
||||
'some/path'
|
||||
);
|
||||
|
||||
expect(extractPathFromURL(['scheme:'], 'scheme:///some/path')).toBe(
|
||||
'some/path'
|
||||
);
|
||||
});
|
||||
|
||||
it('extracts path from URL with protocol and host', () => {
|
||||
expect(
|
||||
extractPathFromURL(
|
||||
['scheme://example.com'],
|
||||
'scheme://example.com/some/path'
|
||||
)
|
||||
).toBe('/some/path');
|
||||
|
||||
expect(
|
||||
extractPathFromURL(['scheme://example.com'], 'scheme:example.com/some/path')
|
||||
).toBe('/some/path');
|
||||
|
||||
expect(
|
||||
extractPathFromURL(
|
||||
['scheme://example.com'],
|
||||
'scheme:///example.com/some/path'
|
||||
)
|
||||
).toBe('/some/path');
|
||||
|
||||
expect(
|
||||
extractPathFromURL(
|
||||
['scheme:///example.com'],
|
||||
'scheme:example.com/some/path'
|
||||
)
|
||||
).toBe('/some/path');
|
||||
|
||||
expect(
|
||||
extractPathFromURL(['scheme:example.com'], 'scheme:example.com/some/path')
|
||||
).toBe('/some/path');
|
||||
|
||||
expect(
|
||||
extractPathFromURL(['scheme:example.com'], 'scheme://example.com/some/path')
|
||||
).toBe('/some/path');
|
||||
|
||||
expect(
|
||||
extractPathFromURL(
|
||||
['scheme:example.com'],
|
||||
'scheme:///example.com/some/path'
|
||||
)
|
||||
).toBe('/some/path');
|
||||
});
|
||||
|
||||
it('extracts path from URL with protocol and host with wildcard', () => {
|
||||
expect(
|
||||
extractPathFromURL(
|
||||
['scheme://*.example.com'],
|
||||
'scheme://test.example.com/some/path'
|
||||
)
|
||||
).toBe('/some/path');
|
||||
|
||||
expect(
|
||||
extractPathFromURL(
|
||||
['scheme://*.example.com'],
|
||||
'scheme:test.example.com/some/path'
|
||||
)
|
||||
).toBe('/some/path');
|
||||
|
||||
expect(
|
||||
extractPathFromURL(
|
||||
['scheme://*.example.com'],
|
||||
'scheme:///test.example.com/some/path'
|
||||
)
|
||||
).toBe('/some/path');
|
||||
|
||||
expect(
|
||||
extractPathFromURL(
|
||||
['scheme:///*.example.com'],
|
||||
'scheme:test.example.com/some/path'
|
||||
)
|
||||
).toBe('/some/path');
|
||||
|
||||
expect(
|
||||
extractPathFromURL(
|
||||
['scheme:*.example.com'],
|
||||
'scheme:test.example.com/some/path'
|
||||
)
|
||||
).toBe('/some/path');
|
||||
|
||||
expect(
|
||||
extractPathFromURL(
|
||||
['scheme:*.example.com'],
|
||||
'scheme://test.example.com/some/path'
|
||||
)
|
||||
).toBe('/some/path');
|
||||
|
||||
expect(
|
||||
extractPathFromURL(
|
||||
['scheme:*.example.com'],
|
||||
'scheme:///test.example.com/some/path'
|
||||
)
|
||||
).toBe('/some/path');
|
||||
});
|
||||
|
||||
it('extracts path from URL with protocol, host and path', () => {
|
||||
expect(
|
||||
extractPathFromURL(
|
||||
['scheme://example.com/test'],
|
||||
'scheme://example.com/test/some/path'
|
||||
)
|
||||
).toBe('/some/path');
|
||||
|
||||
expect(
|
||||
extractPathFromURL(['scheme://example.com'], 'scheme:example.com/some/path')
|
||||
).toBe('/some/path');
|
||||
|
||||
expect(
|
||||
extractPathFromURL(
|
||||
['scheme://example.com/test'],
|
||||
'scheme:///example.com/test/some/path'
|
||||
)
|
||||
).toBe('/some/path');
|
||||
|
||||
expect(
|
||||
extractPathFromURL(
|
||||
['scheme:///example.com/test'],
|
||||
'scheme:example.com/test/some/path'
|
||||
)
|
||||
).toBe('/some/path');
|
||||
|
||||
expect(
|
||||
extractPathFromURL(
|
||||
['scheme:example.com/test'],
|
||||
'scheme:example.com/test/some/path'
|
||||
)
|
||||
).toBe('/some/path');
|
||||
|
||||
expect(
|
||||
extractPathFromURL(
|
||||
['scheme:example.com/test'],
|
||||
'scheme://example.com/test/some/path'
|
||||
)
|
||||
).toBe('/some/path');
|
||||
|
||||
expect(
|
||||
extractPathFromURL(
|
||||
['scheme:example.com/test'],
|
||||
'scheme:///example.com/test/some/path'
|
||||
)
|
||||
).toBe('/some/path');
|
||||
|
||||
expect(
|
||||
extractPathFromURL(
|
||||
['scheme:example.com/test'],
|
||||
'scheme:///example.com//test/some/path'
|
||||
)
|
||||
).toBe('/some/path');
|
||||
|
||||
expect(
|
||||
extractPathFromURL(
|
||||
['scheme:example.com/test'],
|
||||
'scheme:///example.com/test//some/path'
|
||||
)
|
||||
).toBe('/some/path');
|
||||
|
||||
expect(
|
||||
extractPathFromURL(
|
||||
['scheme:example.com/test'],
|
||||
'scheme:///example.com/test/some//path'
|
||||
)
|
||||
).toBe('/some/path');
|
||||
});
|
||||
|
||||
it('returns undefined for non-matching protocol', () => {
|
||||
expect(extractPathFromURL(['scheme://'], 'foo://some/path')).toBe(undefined);
|
||||
|
||||
expect(extractPathFromURL(['scheme://'], 'foo:some/path')).toBe(undefined);
|
||||
|
||||
expect(extractPathFromURL(['scheme://'], 'foo:///some/path')).toBe(undefined);
|
||||
|
||||
expect(extractPathFromURL(['scheme:///'], 'foo:some/path')).toBe(undefined);
|
||||
|
||||
expect(extractPathFromURL(['scheme:'], 'foo:some/path')).toBe(undefined);
|
||||
|
||||
expect(extractPathFromURL(['scheme:'], 'foo://some/path')).toBe(undefined);
|
||||
|
||||
expect(extractPathFromURL(['scheme:'], 'foo:///some/path')).toBe(undefined);
|
||||
});
|
||||
|
||||
it('returns undefined for non-matching path', () => {
|
||||
expect(extractPathFromURL(['scheme://foo'], 'scheme://some/path')).toBe(
|
||||
undefined
|
||||
);
|
||||
|
||||
expect(extractPathFromURL(['scheme://foo'], 'scheme:some/path')).toBe(
|
||||
undefined
|
||||
);
|
||||
|
||||
expect(extractPathFromURL(['scheme://foo'], 'scheme:///some/path')).toBe(
|
||||
undefined
|
||||
);
|
||||
|
||||
expect(extractPathFromURL(['scheme:///foo'], 'scheme:some/path')).toBe(
|
||||
undefined
|
||||
);
|
||||
|
||||
expect(extractPathFromURL(['scheme:foo'], 'scheme:some/path')).toBe(
|
||||
undefined
|
||||
);
|
||||
|
||||
expect(extractPathFromURL(['scheme:foo'], 'scheme://some/path')).toBe(
|
||||
undefined
|
||||
);
|
||||
|
||||
expect(extractPathFromURL(['scheme:foo'], 'scheme:///some/path')).toBe(
|
||||
undefined
|
||||
);
|
||||
});
|
||||
|
||||
it('returns undefined for non-matching host', () => {
|
||||
expect(
|
||||
extractPathFromURL(['scheme://example.com'], 'scheme://foo.com/some/path')
|
||||
).toBe(undefined);
|
||||
|
||||
expect(
|
||||
extractPathFromURL(['scheme://example.com'], 'scheme:foo.com/some/path')
|
||||
).toBe(undefined);
|
||||
|
||||
expect(
|
||||
extractPathFromURL(['scheme://example.com'], 'scheme:///foo.com/some/path')
|
||||
).toBe(undefined);
|
||||
|
||||
expect(
|
||||
extractPathFromURL(['scheme:///example.com'], 'scheme:foo.com/some/path')
|
||||
).toBe(undefined);
|
||||
|
||||
expect(
|
||||
extractPathFromURL(['scheme:example.com'], 'scheme:foo.com/some/path')
|
||||
).toBe(undefined);
|
||||
|
||||
expect(
|
||||
extractPathFromURL(['scheme:example.com'], 'scheme://foo.com/some/path')
|
||||
).toBe(undefined);
|
||||
|
||||
expect(
|
||||
extractPathFromURL(['scheme:example.com'], 'scheme:///foo.com/some/path')
|
||||
).toBe(undefined);
|
||||
});
|
||||
|
||||
it('returns undefined for non-matching host with wildcard', () => {
|
||||
expect(
|
||||
extractPathFromURL(
|
||||
['scheme://*.example.com'],
|
||||
'scheme://test.foo.com/some/path'
|
||||
)
|
||||
).toBe(undefined);
|
||||
|
||||
expect(
|
||||
extractPathFromURL(
|
||||
['scheme://*.example.com'],
|
||||
'scheme:test.foo.com/some/path'
|
||||
)
|
||||
).toBe(undefined);
|
||||
|
||||
expect(
|
||||
extractPathFromURL(
|
||||
['scheme://*.example.com'],
|
||||
'scheme:///test.foo.com/some/path'
|
||||
)
|
||||
).toBe(undefined);
|
||||
|
||||
expect(
|
||||
extractPathFromURL(
|
||||
['scheme:///*.example.com'],
|
||||
'scheme:test.foo.com/some/path'
|
||||
)
|
||||
).toBe(undefined);
|
||||
|
||||
expect(
|
||||
extractPathFromURL(
|
||||
['scheme:*.example.com'],
|
||||
'scheme:test.foo.com/some/path'
|
||||
)
|
||||
).toBe(undefined);
|
||||
|
||||
expect(
|
||||
extractPathFromURL(
|
||||
['scheme:*.example.com'],
|
||||
'scheme://test.foo.com/some/path'
|
||||
)
|
||||
).toBe(undefined);
|
||||
|
||||
expect(
|
||||
extractPathFromURL(
|
||||
['scheme:*.example.com'],
|
||||
'scheme:///test.foo.com/some/path'
|
||||
)
|
||||
).toBe(undefined);
|
||||
});
|
||||
26
packages/native/src/extractPathFromURL.tsx
Normal file
26
packages/native/src/extractPathFromURL.tsx
Normal file
@@ -0,0 +1,26 @@
|
||||
import escapeStringRegexp from 'escape-string-regexp';
|
||||
|
||||
export default function extractPathFromURL(prefixes: string[], url: string) {
|
||||
for (const prefix of prefixes) {
|
||||
const protocol = prefix.match(/^[^:]+:/)?.[0] ?? '';
|
||||
const host = prefix
|
||||
.replace(new RegExp(`^${escapeStringRegexp(protocol)}`), '')
|
||||
.replace(/\/+/g, '/') // Replace multiple slash (//) with single ones
|
||||
.replace(/^\//, ''); // Remove extra leading slash
|
||||
|
||||
const prefixRegex = new RegExp(
|
||||
`^${escapeStringRegexp(protocol)}(/)*${host
|
||||
.split('.')
|
||||
.map((it) => (it === '*' ? '[^/]+' : escapeStringRegexp(it)))
|
||||
.join('\\.')}`
|
||||
);
|
||||
|
||||
const normalizedURL = url.replace(/\/+/g, '/');
|
||||
|
||||
if (prefixRegex.test(normalizedURL)) {
|
||||
return normalizedURL.replace(prefixRegex, '');
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
getStateFromPath as getStateFromPathDefault,
|
||||
NavigationContainerRef,
|
||||
} from '@react-navigation/core';
|
||||
import escapeStringRegexp from 'escape-string-regexp';
|
||||
import extractPathFromURL from './extractPathFromURL';
|
||||
import type { LinkingOptions } from './types';
|
||||
|
||||
type ResultState = ReturnType<typeof getStateFromPathDefault>;
|
||||
@@ -80,24 +80,6 @@ export default function useLinking(
|
||||
getActionFromStateRef.current = getActionFromState;
|
||||
});
|
||||
|
||||
const extractPathFromURL = React.useCallback((url: string) => {
|
||||
for (const prefix of prefixesRef.current) {
|
||||
const protocol = prefix.match(/^[^:]+:\/\//)?.[0] ?? '';
|
||||
const host = prefix.replace(protocol, '');
|
||||
const prefixRegex = new RegExp(
|
||||
`^${escapeStringRegexp(protocol)}${host
|
||||
.split('.')
|
||||
.map((it) => (it === '*' ? '[^/]+' : escapeStringRegexp(it)))
|
||||
.join('\\.')}`
|
||||
);
|
||||
if (prefixRegex.test(url)) {
|
||||
return url.replace(prefixRegex, '');
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}, []);
|
||||
|
||||
const getInitialState = React.useCallback(() => {
|
||||
let state: ResultState | undefined;
|
||||
|
||||
@@ -106,7 +88,9 @@ export default function useLinking(
|
||||
|
||||
if (url != null && typeof url !== 'string') {
|
||||
return url.then((url) => {
|
||||
const path = url ? extractPathFromURL(url) : null;
|
||||
const path = url
|
||||
? extractPathFromURL(prefixesRef.current, url)
|
||||
: null;
|
||||
|
||||
return path
|
||||
? getStateFromPathRef.current(path, configRef.current)
|
||||
@@ -114,7 +98,7 @@ export default function useLinking(
|
||||
});
|
||||
}
|
||||
|
||||
const path = url ? extractPathFromURL(url) : null;
|
||||
const path = url ? extractPathFromURL(prefixesRef.current, url) : null;
|
||||
|
||||
state = path
|
||||
? getStateFromPathRef.current(path, configRef.current)
|
||||
@@ -131,7 +115,7 @@ export default function useLinking(
|
||||
};
|
||||
|
||||
return thenable as PromiseLike<ResultState | undefined>;
|
||||
}, [extractPathFromURL]);
|
||||
}, []);
|
||||
|
||||
React.useEffect(() => {
|
||||
const listener = (url: string) => {
|
||||
@@ -139,7 +123,7 @@ export default function useLinking(
|
||||
return;
|
||||
}
|
||||
|
||||
const path = extractPathFromURL(url);
|
||||
const path = extractPathFromURL(prefixesRef.current, url);
|
||||
const navigation = ref.current;
|
||||
|
||||
if (navigation && path) {
|
||||
@@ -182,7 +166,7 @@ export default function useLinking(
|
||||
};
|
||||
|
||||
return subscribe(listener);
|
||||
}, [enabled, ref, subscribe, extractPathFromURL]);
|
||||
}, [enabled, ref, subscribe]);
|
||||
|
||||
return {
|
||||
getInitialState,
|
||||
|
||||
@@ -3,6 +3,25 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [5.14.2](https://github.com/react-navigation/react-navigation/compare/@react-navigation/stack@5.14.1...@react-navigation/stack@5.14.2) (2021-01-25)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* fix transparent modal on web ([38d6808](https://github.com/react-navigation/react-navigation/commit/38d680833e31e62736da19f79328aec553ced814))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [5.14.1](https://github.com/react-navigation/react-navigation/compare/@react-navigation/stack@5.14.0...@react-navigation/stack@5.14.1) (2021-01-22)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/stack
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# [5.14.0](https://github.com/react-navigation/react-navigation/compare/@react-navigation/stack@5.13.0...@react-navigation/stack@5.14.0) (2021-01-21)
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@react-navigation/stack",
|
||||
"description": "Stack navigator component for iOS and Android with animated transitions and gestures",
|
||||
"version": "5.14.0",
|
||||
"version": "5.14.2",
|
||||
"keywords": [
|
||||
"react-native-component",
|
||||
"react-component",
|
||||
@@ -45,7 +45,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@react-native-community/masked-view": "^0.1.10",
|
||||
"@react-navigation/native": "^5.9.1",
|
||||
"@react-navigation/native": "^5.9.2",
|
||||
"@testing-library/react-native": "^7.1.0",
|
||||
"@types/color": "^3.0.1",
|
||||
"@types/react": "^16.9.53",
|
||||
|
||||
@@ -508,7 +508,7 @@ export default class CardStack extends React.Component<Props, State> {
|
||||
// For the old implementation, it stays the same it was
|
||||
let isScreenActive: Animated.AnimatedInterpolation | 2 | 1 | 0 = 1;
|
||||
|
||||
if (shouldUseActivityState) {
|
||||
if (shouldUseActivityState || Platform.OS === 'web') {
|
||||
if (index < self.length - activeScreensLimit - 1) {
|
||||
// screen should be inactive because it is too deep in the stack
|
||||
isScreenActive = STATE_INACTIVE;
|
||||
|
||||
Reference in New Issue
Block a user