@abide/abide 0.110.2 → 0.110.3
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/CHANGELOG.md +6 -0
- package/docs/RULEBOOK.md +3 -2
- package/package.json +1 -1
- package/src/server/createApp.ts +6 -6
- package/src/shared/mount.ts +6 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @abide/abide
|
|
2
2
|
|
|
3
|
+
## 0.110.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 804b901: the root below a mount is the bare mount, url('/') writing /docs and /docs/ redirected to it ([`9c5d3c3`](https://github.com/briancray/abide/commit/9c5d3c360c27f2d9918fb663d7aff83b22078707))
|
|
8
|
+
|
|
3
9
|
## 0.110.2
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/docs/RULEBOOK.md
CHANGED
|
@@ -1236,8 +1236,9 @@ be refused at construction, naming its `Args` member, and the build MUST refuse
|
|
|
1236
1236
|
19.16 `route.url` MUST hold the address a page is served at, the path `APP_URL` names included, on
|
|
1237
1237
|
the server as in the browser.
|
|
1238
1238
|
|
|
1239
|
-
19.17
|
|
1240
|
-
|
|
1239
|
+
19.17 The root of an app served below the path `APP_URL` names MUST be that path without a trailing
|
|
1240
|
+
`/`, as `url('/')` writes it, and a request for the path with one MUST be redirected 308 to it, by
|
|
1241
|
+
path alone.
|
|
1241
1242
|
|
|
1242
1243
|
19.18 A `Schema` derived per 19.9 MUST refuse a member its type does not declare, wherever the type
|
|
1243
1244
|
carries no index signature.
|
package/package.json
CHANGED
package/src/server/createApp.ts
CHANGED
|
@@ -507,14 +507,14 @@ function stamp(answered: Response): Response {
|
|
|
507
507
|
|
|
508
508
|
/**
|
|
509
509
|
* The request with the mount taken off its address, where it is under the mount — or the redirect
|
|
510
|
-
* to the mount's root, where it asked for the mount with
|
|
510
|
+
* to the mount's root, where it asked for the mount with a `/` after it.
|
|
511
511
|
*
|
|
512
512
|
* 16.10 — A REQUEST UNDER THE MOUNT IS ANSWERED AS THE ADDRESS BELOW IT; one that is not — a proxy
|
|
513
513
|
* that already took the prefix off — is answered as it came.
|
|
514
514
|
*
|
|
515
|
-
* THE MOUNT'S ROOT IS `/docs
|
|
516
|
-
*
|
|
517
|
-
*
|
|
515
|
+
* 19.17 — THE MOUNT'S ROOT IS `/docs`, as `url('/')` writes it, and `/docs/` is sent there so the
|
|
516
|
+
* root has one address. Every address abide writes is absolute under the mount, so none resolves
|
|
517
|
+
* against the page's.
|
|
518
518
|
*/
|
|
519
519
|
function belowMount(request: Request): Request | Response {
|
|
520
520
|
const mount = MOUNT.current()
|
|
@@ -522,10 +522,10 @@ function belowMount(request: Request): Request | Response {
|
|
|
522
522
|
const url = new URL(request.url)
|
|
523
523
|
// A PATH RATHER THAN A URL: the origin this request names is the one it reached, which behind
|
|
524
524
|
// a proxy is not the one the browser asked.
|
|
525
|
-
if (url.pathname === mount)
|
|
525
|
+
if (url.pathname === `${mount}/`)
|
|
526
526
|
return new Response(null, {
|
|
527
527
|
status: 308,
|
|
528
|
-
headers: { location: `${mount}
|
|
528
|
+
headers: { location: `${mount}${url.search}` },
|
|
529
529
|
})
|
|
530
530
|
const below = unmounted(url.pathname)
|
|
531
531
|
if (below === undefined || below === url.pathname) return request
|
package/src/shared/mount.ts
CHANGED
|
@@ -25,10 +25,14 @@ function documentMount(): string {
|
|
|
25
25
|
return documentMountRead
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* An address below the app's root, as the address it is served at. 19.17 — the root below a mount
|
|
30
|
+
* is the bare mount, `/docs` rather than `/docs/`.
|
|
31
|
+
*/
|
|
29
32
|
export function mounted(address: string): string {
|
|
30
33
|
const mount = MOUNT.current()
|
|
31
|
-
|
|
34
|
+
if (mount === '') return address
|
|
35
|
+
return address === '/' ? mount : `${mount}${address}`
|
|
32
36
|
}
|
|
33
37
|
|
|
34
38
|
/**
|