From f64e617ccb6f3fa95e2ca3b839c8aaa087103e21 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Tue, 20 Sep 2022 11:41:38 +0300 Subject: [PATCH] now trailing ':' are trimmed by path.normalize(..) Signed-off-by: Alex A. Naanou --- pwiki/page.js | 18 ++++++++---------- pwiki/path.js | 6 ++++++ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/pwiki/page.js b/pwiki/page.js index a1a78e4..e512b97 100755 --- a/pwiki/page.js +++ b/pwiki/page.js @@ -124,13 +124,14 @@ object.Constructor('BasePage', { }, resolvePathVars: function(path, context={}){ var that = this - return Object.entries(this.path_vars) - .reduce(function(res, [key, func]){ - return res - .replace( - new RegExp('(\\${'+key+'}|\\$'+key+')', 'g'), - func.call(that, context)) - }, path) }, + return pwpath.normalize( + Object.entries(this.path_vars) + .reduce(function(res, [key, func]){ + return res + .replace( + new RegExp('(\\${'+key+'}|\\$'+key+')', 'g'), + func.call(that, context)) + }, path)) }, // page location... // @@ -914,7 +915,6 @@ object.Constructor('Page', BasePage, { // XXX DEPENDS_PATTERN depends.add(src) - handler = handler ?? async function(src, state){ return isolated ? @@ -1036,7 +1036,6 @@ object.Constructor('Page', BasePage, { // XXX DEPENDS_PATTERN depends.add(src) - var pages = src ? (!expandactions && await this.get(src).type == 'action' ? @@ -1295,7 +1294,6 @@ object.Constructor('Page', BasePage, { // XXX DEPENDS_PATTERN depends.add(src) - join = _getBlock('join') ?? join join = join diff --git a/pwiki/path.js b/pwiki/path.js index ba6603a..c757c96 100755 --- a/pwiki/path.js +++ b/pwiki/path.js @@ -123,6 +123,12 @@ module = { // clear the trailing '/'... path.at(-1) == '' && path.pop() + // trim trailing ':'... + path.at(-1) + && path.at(-1).endsWith(':') + && (path.push( + path.pop() + .replace(/:*$/, ''))) /*/ XXX NORMCACHE... var res = format == 'string' ? // special case: root -> keep '/'