Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision b3a1f678

Von Moritz Bunkus vor fast 10 Jahren hinzugefügt

  • ID b3a1f678f8740a4628bb2cf2ff388c08868c2392
  • Vorgänger 6a35b0d4
  • Nachfolger cf263726

SL::CTI::sanitize_number: nur Ziffern zurückliefern

Unterschiede anzeigen:

SL/CTI.pm
40 40
  my $idp              = $config->{international_dialing_prefix} // '00';
41 41

  
42 42
  my $number           = $params{number} // '';
43
  $number              =~ s/[^0-9+\.-]//g;                                     # delete unsupported characters
43
  $number              =~ s/[^0-9+]//g;                                        # delete unsupported characters
44 44
  my $countrycode      = $number =~ s/^(?: $idp | \+ ) ( \d{2} )//x ? $1 : ''; # TODO: countrycodes can have more or less than 2 digits
45 45
  $number              =~ s/^0//x if $countrycode;                             # kill non standard optional zero after global identifier
46
  $number              =~ s{[^0-9]+}{}g;
46 47

  
47 48
  return '' unless $number;
48 49

  
t/cti/call_link.t
12 12
}
13 13

  
14 14
is SL::CTI->call_link(number => '0371 5347 620'),        'controller.pl?action=CTI/call&number=03715347620';
15
is SL::CTI->call_link(number => '0049(0)421-22232 22'),  'controller.pl?action=CTI/call&number=0049421-2223222';
16
is SL::CTI->call_link(number => '+49(0)421-22232 22'),   'controller.pl?action=CTI/call&number=0049421-2223222';
15
is SL::CTI->call_link(number => '0049(0)421-22232 22'),  'controller.pl?action=CTI/call&number=00494212223222';
16
is SL::CTI->call_link(number => '+49(0)421-22232 22'),   'controller.pl?action=CTI/call&number=00494212223222';
17 17
is SL::CTI->call_link(number => 'Tel: +49 40 809064 0'), 'controller.pl?action=CTI/call&number=0049408090640';
18 18

  
19 19
is SL::CTI->call_link(number => '0371 5347 620',        internal => 1), 'controller.pl?action=CTI/call&number=03715347620&internal=1';
20
is SL::CTI->call_link(number => '0049(0)421-22232 22',  internal => 1), 'controller.pl?action=CTI/call&number=0049421-2223222&internal=1';
21
is SL::CTI->call_link(number => '+49(0)421-22232 22',   internal => 1), 'controller.pl?action=CTI/call&number=0049421-2223222&internal=1';
20
is SL::CTI->call_link(number => '0049(0)421-22232 22',  internal => 1), 'controller.pl?action=CTI/call&number=00494212223222&internal=1';
21
is SL::CTI->call_link(number => '+49(0)421-22232 22',   internal => 1), 'controller.pl?action=CTI/call&number=00494212223222&internal=1';
22 22
is SL::CTI->call_link(number => 'Tel: +49 40 809064 0', internal => 1), 'controller.pl?action=CTI/call&number=0049408090640&internal=1';
t/cti/sanitize_number.t
12 12
}
13 13

  
14 14
is SL::CTI->sanitize_number(number => '0371 5347 620'),        '03715347620';
15
is SL::CTI->sanitize_number(number => '0049(0)421-22232 22'),  '0049421-2223222';
16
is SL::CTI->sanitize_number(number => '+49(0)421-22232 22'),   '0049421-2223222';
15
is SL::CTI->sanitize_number(number => '0049(0)421-22232 22'),  '00494212223222';
16
is SL::CTI->sanitize_number(number => '+49(0)421-22232 22'),   '00494212223222';
17 17
is SL::CTI->sanitize_number(number => 'Tel: +49 40 809064 0'), '0049408090640';

Auch abrufbar als: Unified diff