Changeset 23852
- Timestamp:
- Apr 14, 2009, 10:50:32 AM (17 years ago)
- Location:
- branches/neb_distrib_20081210/Nebulous-Server
- Files:
-
- 3 edited
-
Changes (modified) (1 diff)
-
lib/Nebulous/Key.pm (modified) (5 diffs)
-
t/75_parse_neb_key.t (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/neb_distrib_20081210/Nebulous-Server/Changes
r23755 r23852 13 13 hash of a key to change 14 14 - create a pseduo directory structure on key creation 15 - Nebulous::Key parsing and testing improvements 15 16 16 17 0.16 -
branches/neb_distrib_20081210/Nebulous-Server/lib/Nebulous/Key.pm
r23715 r23852 54 54 # strip off volume component if it exists 55 55 $path =~ s|^//([^/]+)||; 56 57 # a new is not allowed to be just a volume specifier, it must have a 58 # path component to it 59 unless (length $path) { 60 die "neb URI scheme requires a path component"; 61 } 56 62 57 63 # ignore key supplied volume name if one is passed as a parameter … … 81 87 # strip leading slashes 82 88 $path =~ s|^/+||; 89 90 # strip leading '.' or '..' 91 $path =~ s|^\.{1,2}||; 83 92 84 93 # remove multiple /'s and trailing slashes … … 92 101 } 93 102 103 94 104 sub parse_neb_volume 95 105 { … … 106 116 } 107 117 118 108 119 sub _stringify_key 109 120 { … … 116 127 return "neb://${soft_volume}${volume}/$path"; 117 128 } 129 118 130 119 131 1; -
branches/neb_distrib_20081210/Nebulous-Server/t/75_parse_neb_key.t
r23754 r23852 10 10 use Test::More; 11 11 12 plan tests => 80;12 plan tests => 99; 13 13 14 14 use lib qw( ./t ./lib ); … … 224 224 } 225 225 226 # root volume references 227 { 228 my $key = parse_neb_key('neb:///'); 229 230 is($key->path, '', 'path'); 231 is($key->volume, undef, 'volume name'); 232 is($key->soft_volume, undef, 'soft volume name'); 233 } 234 235 { 236 my $key = parse_neb_key('neb:///.'); 237 238 is($key->path, '', 'path'); 239 is($key->volume, undef, 'volume name'); 240 is($key->soft_volume, undef, 'soft volume name'); 241 } 242 243 { 244 my $key = parse_neb_key('neb:///..'); 245 246 is($key->path, '', 'path'); 247 is($key->volume, undef, 'volume name'); 248 is($key->soft_volume, undef, 'soft volume name'); 249 } 250 251 { 252 my $key = parse_neb_key('/'); 253 254 is($key->path, '', 'path'); 255 is($key->volume, undef, 'volume name'); 256 is($key->soft_volume, undef, 'soft volume name'); 257 } 258 259 { 260 my $key = parse_neb_key('.'); 261 262 is($key->path, '', 'path'); 263 is($key->volume, undef, 'volume name'); 264 is($key->soft_volume, undef, 'soft volume name'); 265 } 266 267 { 268 my $key = parse_neb_key('..'); 269 270 is($key->path, '', 'path'); 271 is($key->volume, undef, 'volume name'); 272 is($key->soft_volume, undef, 'soft volume name'); 273 } 274 226 275 # key w/ whitespace 227 276 eval { … … 267 316 }; 268 317 like( $@, qr/requires a leading slash/, "leading slash" ); 318 319 # URI w/ volume but w/o path 320 eval { 321 my $key = parse_neb_key('neb://foo'); 322 }; 323 like( $@, qr/requires a path/, "no path" );
Note:
See TracChangeset
for help on using the changeset viewer.
