Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit 1900eb1

Browse files
Foxandxsswardbell
authored andcommitted
docs: replace terminal with pathMatch, base href with '/'
closes #1799
1 parent 527fe50 commit 1900eb1

File tree

12 files changed

+24
-20
lines changed

12 files changed

+24
-20
lines changed

public/docs/_examples/router/ts/app/crisis-center/crisis-center.routes.2.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const CrisisCenterRoutes: RouterConfig = [
1010
{
1111
path: '',
1212
redirectTo: '/crisis-center',
13-
terminal: true
13+
pathMatch: 'full'
1414
},
1515
// #enddocregion redirect
1616
{

public/docs/_examples/router/ts/app/crisis-center/crisis-center.routes.3.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const CrisisCenterRoutes: RouterConfig = [
1212
{
1313
path: '',
1414
redirectTo: '/crisis-center',
15-
terminal: true
15+
pathMatch: 'full'
1616
},
1717
{
1818
path: 'crisis-center',

public/docs/_examples/router/ts/app/crisis-center/crisis-center.routes.4.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const CrisisCenterRoutes: RouterConfig = [
1313
{
1414
path: '',
1515
redirectTo: '/crisis-center',
16-
terminal: true
16+
pathMatch: 'full'
1717
},
1818
{
1919
path: 'crisis-center',

public/docs/_examples/router/ts/app/crisis-center/crisis-center.routes.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const CrisisCenterRoutes: RouterConfig = [
1212
{
1313
path: '',
1414
redirectTo: '/crisis-center',
15-
terminal: true
15+
pathMatch: 'full'
1616
},
1717
{
1818
path: 'crisis-center',

public/docs/_examples/router/ts/index.1.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<html>
44
<head>
55
<!-- #docregion base-href -->
6-
<base href=".">
6+
<base href="/">
77
<!-- #enddocregion base-href -->
88
<title>Router Sample v.1</title>
99
<meta charset="UTF-8">

public/docs/_examples/router/ts/index.2.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<!-- #docregion -->
33
<html>
44
<head>
5-
<base href=".">
5+
<base href="/">
66
<title>Router Sample v.2</title>
77
<meta charset="UTF-8">
88
<meta name="viewport" content="width=device-width, initial-scale=1">

public/docs/_examples/router/ts/index.3.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<!-- #docregion -->
33
<html>
44
<head>
5-
<base href=".">
5+
<base href="/">
66
<title>Router Sample v.3</title>
77
<meta charset="UTF-8">
88
<meta name="viewport" content="width=device-width, initial-scale=1">

public/docs/_examples/router/ts/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<html>
55
<head>
66
<!-- Set the base href -->
7-
<base href=".">
7+
<base href="/">
88
<title>Router Sample</title>
99
<meta charset="UTF-8">
1010
<meta name="viewport" content="width=device-width, initial-scale=1">

public/docs/_examples/toh-5/ts/app/app.routes.1.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const routes: RouterConfig = [
1111
{
1212
path: '',
1313
redirectTo: '/dashboard',
14-
terminal: true
14+
pathMatch: 'full'
1515
},
1616
// #enddocregion redirect-route
1717
// #docregion dashboard-route

public/docs/_examples/toh-5/ts/app/app.routes.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const routes: RouterConfig = [
1111
{
1212
path: '',
1313
redirectTo: '/dashboard',
14-
terminal: true
14+
pathMatch: 'full'
1515
},
1616
{
1717
path: 'dashboard',

public/docs/_examples/toh-6/ts/app/app.routes.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const routes: RouterConfig = [
99
{
1010
path: '',
1111
redirectTo: '/dashboard',
12-
terminal: true
12+
pathMatch: 'full'
1313
},
1414
{
1515
path: 'dashboard',

public/docs/ts/latest/guide/router.jade

+13-9
Original file line numberDiff line numberDiff line change
@@ -975,23 +975,27 @@ code-example(format="").
975975
That doesn't match any of our configured routes which means that our application won't display any component when it's launched.
976976
The user must click one of the navigation links to trigger a navigation and display something.
977977

978-
We want the application to display the list of crises as it would if we pasted `localhost:3000/crisis-center/` into the address bar.
978+
We prefer that the application display the list of crises as it would if the user clicked the "Crisis Center" link or pasted `localhost:3000/crisis-center/` into the address bar.
979979
This is our intended default route.
980980

981-
We can arrange for that behavior in several ways.
982-
One way is to use a `redirect` to transparently navigate from one route to another.
983-
984-
In our example, we'll add a route to match our initial URL and redirect to our `crisis-center` route:
981+
The preferred solution is to add a `redirect` route that transparently translates from the initial URL (`''`) to the preferred default path (`/crisis-center`):
985982
+makeExample('router/ts/app/crisis-center/crisis-center.routes.2.ts', 'redirect', 'app/crisis-center/crisis-center.routes.ts (redirect route)' )(format='.')
986983

987984
:marked
988-
Since we only want to redirect when our path specifically matches `''`, we've added an extra configuration
989-
to our route using `terminal: true`. Mainly for redirects, the `terminal` property tells the router
990-
whether or not it should continue matching our URL against the rest of our defined routes.
985+
A redirect route requires a `pathMatch` property to tell the router how to match a URL to the path of a route.
986+
In this app, the router should select the route to `CrisisCenterComponent` when the *entire URL* matches `''`,
987+
so we set the `pathMatch` value to `'full'`.
991988

992989
.l-sub-section
993990
:marked
994-
We'll discuss redirects further in a future update to this chapter.
991+
The other possible `pathMatch` value is `'prefix'` which tells the router
992+
to match the redirect route to _any_ URL that _begins_ with the redirect route's _prefix_ path.
993+
994+
That's not what we want in our use case. The `''` prefix path matches _every_ URL.
995+
We should redirect to the `CrisisCenterComponent` _only_ when the _entire_ url is `''`
996+
(or the equivalent `'/'`).
997+
998+
We'll discuss redirects in more detail in a future update to this chapter.
995999

9961000
:marked
9971001
The updated route definitions look like this:

0 commit comments

Comments
 (0)