waibu 2.11.3 → 2.12.0

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/index.js CHANGED
@@ -449,12 +449,13 @@ async function factory (pkgName) {
449
449
  /**
450
450
  * Get route path by route's name:
451
451
  * - If it is a ```mailto:``` or ```tel:``` url, it returns as is
452
+ * - If it starts with ```:/```, name will be prefixed with its ```ns``` automatically
452
453
  * - If it is a ns based name, it will be parsed first
453
454
  *
454
455
  * @method
455
456
  * @param {string} name
456
457
  * @param {Object} [options={}] - Options object
457
- * @param {string} [options.base=waibu] - Base namespace
458
+ * @param {string} [options.ns=waibu] - Base namespace
458
459
  * @param {boolean} [options.guessHost] - If true, guest host if host is not set
459
460
  * @param {Object} [options.query={}] - Query string's object. If provided, it will be added to returned value
460
461
  * @param {Object} [options.params={}] - Parameter object. If provided, it will be merged to returned value
@@ -465,12 +466,13 @@ async function factory (pkgName) {
465
466
  const { defaultsDeep } = this.app.lib.aneka
466
467
  const { isEmpty, get, trimEnd, trimStart } = this.app.lib._
467
468
  const { breakNsPath } = this.app.bajo
468
- const { query = {}, base = this.ns, params = {}, guessHost, defaults = {} } = options
469
+ const { query = {}, ns = this.ns, params = {}, guessHost, defaults = {}, uriEncoded } = options
469
470
 
470
- const plugin = getPlugin(base)
471
+ const plugin = getPlugin(ns)
471
472
  const cfg = plugin.config ?? {}
472
473
  let info = {}
473
474
  if (name.startsWith('mailto:') || name.startsWith('tel:')) return name
475
+ if (name.slice(0, 2) === ':/') name = ns + name
474
476
  if (['%', '.', '/', '?', '#'].includes(name[0]) || name.slice(1, 2) === ':') info.path = name
475
477
  else if (['~'].includes(name[0])) info.path = name.slice(1)
476
478
  else {
@@ -491,7 +493,7 @@ async function factory (pkgName) {
491
493
  let url = info.path
492
494
  const langDetector = get(cfg, 'intl.detectors', [])
493
495
  if (info.ns) url = trimEnd(langDetector.includes('path') ? `/${params.lang ?? ''}${this.routeDir(info.ns)}${info.path}` : `${this.routeDir(info.ns)}${info.path}`, '/')
494
- if (options.uriEncoded) url = url.split('/').map(u => encodeURI(u)).join('/')
496
+ if (uriEncoded) url = url.split('/').map(u => encodeURI(u)).join('/')
495
497
  info.qs = defaultsDeep({}, query, info.qs)
496
498
  if (!isEmpty(info.qs)) url += '?' + this.qs.stringify(info.qs)
497
499
  if (!url.startsWith('http') && guessHost) url = `http://${this.config.server.host}:${this.config.server.port}/${trimStart(url, '/')}`
@@ -64,7 +64,7 @@ export async function notFound (err, req, reply) {
64
64
  reply.code(404)
65
65
  const resp = await interceptor.call(this, 'notFoundHandler', err, req, reply)
66
66
  if (resp) return resp
67
- if (err.noContent) return ''
67
+ if (err && err.noContent) return ''
68
68
  const payload = {
69
69
  text: req.t('notFound%s%s', req.t('route'), req.url),
70
70
  title: req.t('pageNotFound')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waibu",
3
- "version": "2.11.3",
3
+ "version": "2.12.0",
4
4
  "description": "Web Framework for Bajo",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/wiki/CHANGES.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changes
2
2
 
3
+ ## 2026-05-16
4
+
5
+ - [2.12.0] Change in ```routeDir()```
6
+ - [2.12.0] Change in ```routePath()```
7
+
8
+ ## 2026-05-11
9
+
10
+ - [2.11.4] Bug fix in ```handle-not-found.js```
11
+
3
12
  ## 2026-05-03
4
13
 
5
14
  - [2.11.2] Bug fix in ```handle-not-found.js```