Skip to content

Commit

Permalink
fixed decamelize of multiple uppercase characters
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jan 11, 2010
1 parent 92514e6 commit 8565fa5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions Changes
Expand Up @@ -39,6 +39,7 @@ This file documents the revision history for Perl extension Mojo.
param decoding.
- Fixed format detection bug. (marcus)
- Fixed named url_for and added tests. (marcus)
- Fixed decamelize of multiple uppercase characters.

0.999914 2009-11-24 00:00:00
- Added the Mojolicious plugin system.
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/ByteStream.pm
Expand Up @@ -364,7 +364,7 @@ sub decamelize {

# Split
my @words;
push @words, $1 while ($self->{bytestream} =~ s/([A-Z]+[^A-Z]*)//);
push @words, $1 while ($self->{bytestream} =~ s/([A-Z]{1}[^A-Z]*)//);

# Case
@words = map {lc} @words;
Expand Down
6 changes: 5 additions & 1 deletion t/mojo/bytestream.t
Expand Up @@ -10,7 +10,7 @@ use utf8;
# Homer, we're going to ask you a few simple yes or no questions.
# Do you understand?
# Yes. *lie dectector blows up*
use Test::More tests => 35;
use Test::More tests => 37;

use_ok('Mojo::ByteStream', 'b');

Expand All @@ -19,12 +19,16 @@ my $stream = b('foo_bar_baz');
is($stream->camelize, 'FooBarBaz');
$stream = b('FooBarBaz');
is($stream->camelize, 'Foobarbaz');
$stream = b('foo_b_b');
is($stream->camelize, 'FooBB');

# decamelize
$stream = b('FooBarBaz');
is($stream->decamelize, 'foo_bar_baz');
$stream = b('foo_bar_baz');
is($stream->decamelize, 'foo_bar_baz');
$stream = b('FooBB');
is($stream->decamelize, 'foo_b_b');

# b64_encode
$stream = b('foobar$%^&3217');
Expand Down

0 comments on commit 8565fa5

Please sign in to comment.