From: Paul Donald Date: Thu, 19 Dec 2024 17:43:10 +0000 (+0000) Subject: luci-base: modify path function to allow URI parameters X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=7c2cde52dbb14d5e878ca775946db9b3f13dcf1d;p=project%2Fluci.git luci-base: modify path function to allow URI parameters Allows usage such as: L.url("admin", "system", "package-manager", "?query=package") Signed-off-by: Paul Donald --- diff --git a/modules/luci-base/htdocs/luci-static/resources/luci.js b/modules/luci-base/htdocs/luci-static/resources/luci.js index 24e17b9ad6..aae9a2abce 100644 --- a/modules/luci-base/htdocs/luci-static/resources/luci.js +++ b/modules/luci-base/htdocs/luci-static/resources/luci.js @@ -2792,7 +2792,9 @@ * Construct a relative URL path from the given prefix and parts. * The resulting URL is guaranteed to only contain the characters * `a-z`, `A-Z`, `0-9`, `_`, `.`, `%`, `,`, `;`, and `-` as well - * as `/` for the path separator. + * as `/` for the path separator. Suffixing '?x=y&foo=bar' URI + * parameters also limited to the aforementioned characters is + * permissible. * * @instance * @memberof LuCI @@ -2812,8 +2814,8 @@ var url = [ prefix || '' ]; for (var i = 0; i < parts.length; i++) - if (/^(?:[a-zA-Z0-9_.%,;-]+\/)*[a-zA-Z0-9_.%,;-]+$/.test(parts[i])) - url.push('/', parts[i]); + if (/^(?:[a-zA-Z0-9_.%,;-]+\/)*[a-zA-Z0-9_.%,;-]+$/.test(parts[i]) || /^\?[a-zA-Z0-9_.%=&;-]+$/.test(parts[i])) + url.push(parts[i].startsWith('?') ? parts[i] : '/' + parts[i]); if (url.length === 1) url.push('/'); @@ -2827,7 +2829,9 @@ * * The resulting URL is guaranteed to only contain the characters * `a-z`, `A-Z`, `0-9`, `_`, `.`, `%`, `,`, `;`, and `-` as well - * as `/` for the path separator. + * as `/` for the path separator. Suffixing '?x=y&foo=bar' URI + * parameters also limited to the aforementioned characters is + * permissible. * * @instance * @memberof LuCI @@ -2849,7 +2853,9 @@ * * The resulting URL is guaranteed to only contain the characters * `a-z`, `A-Z`, `0-9`, `_`, `.`, `%`, `,`, `;`, and `-` as well - * as `/` for the path separator. + * as `/` for the path separator. Suffixing '?x=y&foo=bar' URI + * parameters also limited to the aforementioned characters is + * permissible. * * @instance * @memberof LuCI @@ -2871,7 +2877,9 @@ * * The resulting URL is guaranteed to only contain the characters * `a-z`, `A-Z`, `0-9`, `_`, `.`, `%`, `,`, `;`, and `-` as well - * as `/` for the path separator. + * as `/` for the path separator. Suffixing '?x=y&foo=bar' URI + * parameters also limited to the aforementioned characters is + * permissible. * * @instance * @memberof LuCI