Comparing version 15.0.1 to 15.1.0
# CHANGELOG | ||
## 15.1.0 | ||
Router urls now does not have last slash when optional parameter is not defined. | ||
Component now inherit from BobrilCtx which save some bytes from bundle. | ||
## 15.0.1 | ||
@@ -4,0 +10,0 @@ |
{ | ||
"name": "bobril", | ||
"version": "15.0.1", | ||
"version": "15.1.0", | ||
"description": "Component Oriented MVC Framework with virtual DOM and CSS", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -146,4 +146,4 @@ import { | ||
const paramCompileMatcher = /:([a-zA-Z_$][a-zA-Z0-9_$]*)|[*.()\[\]\\+|{}^$]/g; | ||
const paramInjectMatcher = /:([a-zA-Z_$][a-zA-Z0-9_$?]*[?]?)|[*]/g; | ||
const paramCompileMatcher = /(\/?):([a-zA-Z_$][a-zA-Z0-9_$]*)([?]?)|[*.()\[\]\\+|{}^$]/g; | ||
const paramInjectMatcher = /(\/?)(?::([a-zA-Z_$][a-zA-Z0-9_$?]*[?]?)|[*])/g; | ||
@@ -157,13 +157,16 @@ let compiledPatterns: { | ||
var paramNames: Array<string> = []; | ||
var source = pattern.replace(paramCompileMatcher, (match: string, paramName: string) => { | ||
if (paramName) { | ||
paramNames.push(paramName); | ||
return "([^/]+)"; | ||
} else if (match === "*") { | ||
paramNames.push("splat"); | ||
return "(.*?)"; | ||
} else { | ||
return "\\" + match; | ||
var source = pattern.replace( | ||
paramCompileMatcher, | ||
(match: string, leadingSlash: string | undefined, paramName: string, optionalParamChar: string = "") => { | ||
if (paramName) { | ||
paramNames.push(paramName); | ||
return (leadingSlash ? "(?:/([^/?#]+))" : "([^/?#]+)") + optionalParamChar; | ||
} else if (match === "*") { | ||
paramNames.push("splat"); | ||
return "(.*?)"; | ||
} else { | ||
return "\\" + match; | ||
} | ||
} | ||
}); | ||
); | ||
@@ -205,27 +208,30 @@ compiledPatterns[pattern] = { | ||
return pattern.replace(paramInjectMatcher, (_match: string, paramName: string) => { | ||
paramName = paramName || "splat"; | ||
return ( | ||
pattern.replace(paramInjectMatcher, (_match: string, leadingSlash: string = "", paramName: string) => { | ||
paramName = paramName || "splat"; | ||
// If param is optional don't check for existence | ||
if (paramName.slice(-1) !== "?") { | ||
if (params![paramName] == undefined) | ||
throw new Error('Missing "' + paramName + '" parameter for path "' + pattern + '"'); | ||
} else { | ||
paramName = paramName.slice(0, -1); | ||
if (params![paramName] == undefined) { | ||
return ""; | ||
// If param is optional don't check for existence | ||
if (paramName.slice(-1) !== "?") { | ||
if (params![paramName] == undefined) | ||
throw new Error('Missing "' + paramName + '" parameter for path "' + pattern + '"'); | ||
} else { | ||
paramName = paramName.slice(0, -1); | ||
if (params![paramName] == undefined) { | ||
return ""; | ||
} | ||
} | ||
} | ||
var segment: string | undefined; | ||
if (paramName === "splat" && Array.isArray(params![paramName])) { | ||
segment = params![paramName]![splatIndex++]; | ||
var segment: string | undefined; | ||
if (paramName === "splat" && Array.isArray(params![paramName])) { | ||
segment = params![paramName]![splatIndex++]; | ||
if (segment == undefined) throw new Error("Missing splat # " + splatIndex + ' for path "' + pattern + '"'); | ||
} else { | ||
segment = params![paramName]; | ||
} | ||
if (segment == undefined) | ||
throw new Error("Missing splat # " + splatIndex + ' for path "' + pattern + '"'); | ||
} else { | ||
segment = params![paramName]; | ||
} | ||
return encodeUrlPath(segment); | ||
}); | ||
return leadingSlash + encodeUrlPath(segment); | ||
}) || "/" | ||
); | ||
} | ||
@@ -232,0 +238,0 @@ |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
376212
9015