While the jsdoc for this function describes a string[] parameter, this
seemingly was not handled; consistent usage of various
L.(url|resource|etc) is multiple strings that become object properties.
E.g.:
L.resource('lldpd/lldpd.css');
L.url("admin", "system", "leds");
which become e.g.:
Arguments { 0: "admin/network", 1: "routes", … }
Handle a string[] parameter, by re-entering the function with any
Array[] parameter.
follow-up fix to
7c2cde52dbb14d5e878ca775946db9b3f13dcf1d
This prevents:
TypeError
parts[i].startsWith is not a function
Signed-off-by: Paul Donald <newtwen+github@gmail.com>
path(prefix = '', parts) {
const url = [ prefix ];
- for (let i = 0; i < parts.length; 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]);
+ for (let i = 0; i < parts.length; i++){
+ const part = parts[i];
+ if (Array.isArray(part))
+ url.push(this.path('', part));
+ else
+ if (/^(?:[a-zA-Z0-9_.%,;-]+\/)*[a-zA-Z0-9_.%,;-]+$/.test(part) || /^\?[a-zA-Z0-9_.%=&;-]+$/.test(part))
+ url.push(part.startsWith('?') ? part : '/' + part);
+ }
if (url.length === 1)
url.push('/');