@nxtedition/lib 23.5.12 → 23.5.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.
Files changed (3) hide show
  1. package/couch.js +6 -1
  2. package/http.js +5 -0
  3. package/package.json +1 -1
package/couch.js CHANGED
@@ -7,6 +7,7 @@ import { defaultDelay as delay } from './http.js'
7
7
  import urljoin from 'url-join'
8
8
  import { AbortError } from './errors.js'
9
9
  import { dispatch, Agent, Pool, request as undiciRequest } from '@nxtedition/nxt-undici'
10
+ import urlJoin from 'url-join'
10
11
 
11
12
  export function makeCouch(opts) {
12
13
  let config
@@ -254,7 +255,7 @@ export function makeCouch(opts) {
254
255
  const query = { ...params, feed: live ? 'continuous' : 'normal' }
255
256
 
256
257
  const ureq = {
257
- path: `${dbPathname}/_changes`,
258
+ path: urlJoin(dbPathname, '/_changes'),
258
259
  origin: dbOrigin,
259
260
  query,
260
261
  headers: body
@@ -1067,6 +1068,10 @@ export function request(url, opts) {
1067
1068
 
1068
1069
  url = opts.url
1069
1070
 
1071
+ if (typeof url === 'string') {
1072
+ url = new URL(url)
1073
+ }
1074
+
1070
1075
  let origin = url.origin
1071
1076
  if (!origin) {
1072
1077
  const protocol = url.protocol ?? 'http:'
package/http.js CHANGED
@@ -73,6 +73,11 @@ export class Context {
73
73
  if (this.#url === undefined) {
74
74
  this.#url = requestTarget(this.#req)
75
75
  }
76
+
77
+ if (!this.#url) {
78
+ throw new createError.BadRequest('invalid url')
79
+ }
80
+
76
81
  return this.#url
77
82
  }
78
83
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "23.5.12",
3
+ "version": "23.5.14",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "type": "module",