Permalink
Browse files
fix(linky): throw error if input is not a string
BREAKING CHANGE: Before this change, the filter assumed that the input (if not undefined/null) was of type 'string' and that certain methods (such as `.match()`) would be available on it. Passing a non-string value would most likely result in a not-very-useful error being thrown (trying to call a method that does not exist) or in unexpected behavior (if the input happened to have the assumed methods). After this change, a proper (informative) error will be thrown. If you want to pass non-string values through `linky`, you need to explicitly convert them to strings first. Since input values could be initialized asynchronously, `undefined` or `null` will still be returned unchanged (without throwing an error). Closes #13547 Closes #13693
- Loading branch information
Showing
with
53 additions
and 1 deletion.
| @@ -0,0 +1,16 @@ | ||
| @ngdoc error | ||
| @name linky:notstring | ||
| @fullName Not a string | ||
| @description | ||
|
|
||
| This error occurs when {@link ngSanitize.linky linky} is used with a non-empty, non-string value: | ||
| ```html | ||
| <div ng-bind-html="42 | linky"></div> | ||
| ``` | ||
|
|
||
| `linky` is supposed to be used with string values only, and therefore assumes that several methods | ||
| (such as `.match()`) are available on the passed in value. | ||
| The value can be initialized asynchronously and therefore null or undefined won't throw this error. | ||
|
|
||
| If you want to pass non-string values to `linky` (e.g. Objects whose `.toString()` should be | ||
| utilized), you need to manually convert them to strings. |