Make it return safe html

gh-pages
Matteo Suppo 10 years ago
parent d398fa10e3
commit 5a4846e7a0

@ -1,7 +1,7 @@
'use strict'; 'use strict';
angular.module('diff', []) angular.module('diff', [])
.filter('diff', function () { .filter('diff', function ($sce) {
/* /*
* Javascript Diff Algorithm * Javascript Diff Algorithm
@ -173,6 +173,6 @@ angular.module('diff', [])
// Actual filter // Actual filter
return function(input, match) { return function(input, match) {
return diffString(input, match); return $sce.trustAsHtml(diffString(input, match));
}; };
}); });

@ -9,7 +9,8 @@ describe('filter', function() {
it('should convert a string to the diff value with another string', inject(function(diffFilter) { it('should convert a string to the diff value with another string', inject(function(diffFilter) {
expect(diffFilter( expect(diffFilter(
'The red brown fox jumped over the rolling log.', 'The red brown fox jumped over the rolling log.',
'The brown spotted fox leaped over the rolling log')).toBe( 'The brown spotted fox leaped over the rolling log')
.$$unwrapTrustedValue()).toBe(
' The <del>red </del> brown <ins>spotted </ins> fox <del>jumped </del><ins>leaped </ins> over the rolling <del>log.\n</del><ins>log\n</ins>'); ' The <del>red </del> brown <ins>spotted </ins> fox <del>jumped </del><ins>leaped </ins> over the rolling <del>log.\n</del><ins>log\n</ins>');
})); }));
}); });