Compare commits

..

7 Commits

Author SHA1 Message Date
Kyle Fang
073f04b6eb test: rename screen 2021-06-27 09:54:36 +08:00
Kyle Fang
ed37e6aec0 docs: add comments on sort 2021-06-27 07:37:25 +08:00
Kyle Fang
f80ed7790e Merge branch 'main' of github.com:react-navigation/react-navigation into fix/sortOnPaths 2021-06-25 18:25:54 +08:00
Cedric van Putten
4c16083d51 chore: upgrade to expo-github-actions v6 2021-06-23 15:40:22 +02:00
Satyajit Sahoo
e7631ea239 chore: comment on closed issues regarding watching 2021-06-15 03:32:04 +02:00
Kyle Fang
32fe3f17d0 test: add case on :params 2021-06-14 15:39:37 +08:00
Kyle Fang
b7c5305453 fix: move :hello to bottom along with * 2021-06-14 15:38:36 +08:00
5 changed files with 60 additions and 26 deletions

31
.github/workflows/closed-issue.yml vendored Normal file
View File

@@ -0,0 +1,31 @@
name: Comment on closed issue
on:
issue_comment:
types: [created]
jobs:
closed-issue:
runs-on: ubuntu-latest
if: ${{ github.event.issue.state == 'closed' }}
steps:
- uses: actions/github-script@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const body = "Hey! This issue is closed and isn't watched by the core team. You are welcome to discuss the issue with others in this thread, but if you think this issue is still valid and needs to be tracked, please open a new issue with a repro.";
const comments = await github.issues.listComments({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
});
if (comments.data.some(comment => comment.body === body)) {
return;
}
await github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body,
});

View File

@@ -16,10 +16,9 @@ jobs:
node-version: 14.x
- name: Setup Expo
uses: expo/expo-github-action@v5
uses: expo/expo-github-action@v6
with:
expo-token: ${{ secrets.EXPO_TOKEN }}
expo-cache: true
token: ${{ secrets.EXPO_TOKEN }}
- name: Restore yarn cache
id: yarn-cache

View File

@@ -19,10 +19,9 @@ jobs:
node-version: 14.x
- name: Setup Expo
uses: expo/expo-github-action@v5
uses: expo/expo-github-action@v6
with:
expo-token: ${{ secrets.EXPO_TOKEN }}
expo-cache: true
token: ${{ secrets.EXPO_TOKEN }}
- name: Restore yarn cache
id: yarn-cache

View File

@@ -2196,6 +2196,7 @@ it('tries to match wildcard patterns at the end', () => {
path: '/bar/:id/',
screens: {
404: '*',
UserProfile: ':userSlug',
Test: 'test',
},
},

View File

@@ -143,27 +143,31 @@ export default function getStateFromPath<ParamList extends {}>(
const aParts = a.pattern.split('/');
const bParts = b.pattern.split('/');
const aWildcardIndex = aParts.indexOf('*');
const bWildcardIndex = bParts.indexOf('*');
// If only one of the patterns has a wildcard, move it down in the list
if (aWildcardIndex === -1 && bWildcardIndex !== -1) {
return -1;
for (let i = 0; i < Math.max(aParts.length, bParts.length); i++) {
// if b is longer, b get higher priority
if (aParts[i] == null) {
return 1;
}
// if a is longer, a get higher priority
if (bParts[i] == null) {
return -1;
}
const aWildCard = aParts[i] === '*' || aParts[i].startsWith(':');
const bWildCard = bParts[i] === '*' || bParts[i].startsWith(':');
// if both are wildcard we compare next component
if (aWildCard && bWildCard) {
continue;
}
// if only a is wild card, b get higher priority
if (aWildCard) {
return 1;
}
// if only b is wild card, a get higher priority
if (bWildCard) {
return -1;
}
}
if (aWildcardIndex !== -1 && bWildcardIndex === -1) {
return 1;
}
if (aWildcardIndex === bWildcardIndex) {
// If `b` has more `/`, it's more exhaustive
// So we move it up in the list
return bParts.length - aParts.length;
}
// If the wildcard appears later in the pattern (has higher index), it's more specific
// So we move it up in the list
return bWildcardIndex - aWildcardIndex;
return bParts.length - aParts.length;
});
// Check for duplicate patterns in the config