Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

normalize "/a//" to "a" (affects Morpheus::Defaults/Overrides etc.)

  • Loading branch information...
commit 135cf5a06ab29598d7dd7fcc058b67704c877b3a 1 parent 69eea38
@druxa authored
View
2  .gitignore
@@ -1,4 +1,4 @@
-/.debuild
+/debuild
/Morpheus-*
/.build
/libmorpheus-perl*
View
1  Changes
@@ -1,6 +1,7 @@
Revision history for Morpheus
{{$NEXT}}
+ * normalize "/a//" to "a" (affects Morpheus::Defaults/Overrides etc.)
0.34 Sat Nov 13, 2010
* call dh_perldeps when possible
View
6 debian/changelog
@@ -1,3 +1,9 @@
+libmorpheus-perl (0.35) stable; urgency=low
+
+ * normalize "/a//" to "a" (affects Morpheus::Defaults/Overrides etc.)
+
+ -- Andrei Mishchenko <druxa@yandex-team.ru> Thu, 16 Dec 2010 17:12:07 +0300
+
libmorpheus-perl (0.34) stable; urgency=low
* get rid of Sys::Hostname::Long and parent dependencies
View
2  dist.ini
@@ -1,5 +1,5 @@
name = Morpheus
-version = 0.34
+version = 0.35
author = Andrei Mishchenko <druxa@yandex-team.ru>
license = Perl_5
copyright_holder = Yandex LLC
View
3  lib/Morpheus/Utils.pm
@@ -20,8 +20,7 @@ sub normalize ($) {
my $result = { %$data };
for my $key ( keys %$data) {
my @keys = @{key($key)};
- next if @keys == 1;
-
+ next if @keys == 1 and $keys[0] eq $key; # "/a//" -> "a"
my $value = delete $result->{$key};
my $p = my $patch = {};
$p = $p->{$_} = {} for splice @keys, 0, -1;
View
23 t/normalize.t
@@ -0,0 +1,23 @@
+#!/usr/bin/perl
+package Morpheus::Test::Normalize;
+
+use strict;
+use warnings;
+
+use base qw(Test::Class);
+use Test::More;
+use Symbol;
+
+use lib 'lib';
+
+use Morpheus::Utils qw(normalize);
+
+sub general : Test(4) {
+
+ is_deeply(normalize({"a/b" => 1}), {a=>{b=>1}}, "basic test");
+ is_deeply(normalize({"/a/b//" => 1}), {a=>{b=>1}}, "extra slashes");
+ is_deeply(normalize({"/a//" => 1}), {a=>1}, "extra slashes in simple key");
+ is_deeply(normalize({a => {b => 1}, "a/c" => 2, "/a/" => {d => 3}}), {a=>{b => 1, c => 2, d => 3}}, "normalize merges");
+}
+
+__PACKAGE__->new->runtests;
Please sign in to comment.
Something went wrong with that request. Please try again.