Skip to content

Commit

Permalink
fix(NumberPipe): fix broken RegExp
Browse files Browse the repository at this point in the history
introduced in 7498050 (#9308)
  • Loading branch information
vicb committed Jun 17, 2016
1 parent 773c349 commit 49bf3f5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions modules/@angular/common/src/pipes/number_pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {NumberWrapper, RegExpWrapper, Type, isBlank, isNumber, isPresent} from '
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';

var defaultLocale: string = 'en-US';
const _NUMBER_REGEXP = /^(\d+)?\.((\d+)(\-(\d+))?)?$'/g;
const _NUMBER_FORMAT_REGEXP = /^(\d+)?\.((\d+)(\-(\d+))?)?$/g;

/**
* Internal function to format numbers used by Decimal, Percent and Date pipes.
Expand All @@ -19,7 +19,7 @@ function formatNumber(
}
var minInt = 1, minFraction = 0, maxFraction = 3;
if (isPresent(digits)) {
var parts = RegExpWrapper.firstMatch(_NUMBER_REGEXP, digits);
var parts = RegExpWrapper.firstMatch(_NUMBER_FORMAT_REGEXP, digits);
if (isBlank(parts)) {
throw new BaseException(`${digits} is not a valid digit info for number pipes`);
}
Expand Down
2 changes: 1 addition & 1 deletion modules/@angular/common/test/pipes/number_pipe_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export function main() {
expect(pipe.transform(123, '.2')).toEqual('123.00');
expect(pipe.transform(1, '3.')).toEqual('001');
expect(pipe.transform(1.1, '3.4-5')).toEqual('001.1000');

expect(pipe.transform(1.123456, '3.4-5')).toEqual('001.12346');
expect(pipe.transform(1.1234)).toEqual('1.123');
});
Expand Down Expand Up @@ -54,6 +53,7 @@ export function main() {
it('should return correct value for numbers', () => {
expect(pipe.transform(123)).toEqual('USD123');
expect(pipe.transform(12, 'EUR', false, '.2')).toEqual('EUR12.00');
expect(pipe.transform(5.123, 'USD', false, '.0-2')).toEqual('USD5.12');
});

it('should not support other objects',
Expand Down

0 comments on commit 49bf3f5

Please sign in to comment.