$$self = uri_join($scheme, $auth, $path, $query, $frag);
}
$path =~ s!\A/+!!;
- $path =~ m!\A[^;/]+;UIDVALIDITY=([1-9][0-9]*)\b!i ? ($1 + 0) : undef;
+ $path =~ m!\A[^;]+;UIDVALIDITY=([1-9][0-9]*)\b!i ?
+ ($1 + 0) : undef;
}
sub uid {
$path =~ s!/;UID=[^;/]*\b!!i;
} else {
$path =~ s!/;UID=[^;/]*\b!/;UID=$val!i or
- $path .= ";UID=$val";
+ $path .= "/;UID=$val";
}
$$self = uri_join($scheme, $auth, $path, $query);
}
- $path =~ m!\A/[^/;]+(?:;UIDVALIDITY=[^;/]+)?/;UID=([1-9][0-9]*)\b!i ?
+ $path =~ m!\A/[^;]+(?:;UIDVALIDITY=[^;/]+)?/;UID=([1-9][0-9]*)\b!i ?
($1 + 0) : undef;
}
is($cred->{password}, undef, 'password is undef in array context');
$uri = PublicInbox::URIimap->new('imap://u@example.com/slash/separator');
is($uri->mailbox, 'slash/separator', "`/' separator accepted");
+is($uri->uidvalidity(6), 6, "UIDVALIDITY set with `/' separator");
+is($$uri, 'imap://u@example.com/slash/separator;UIDVALIDITY=6',
+ "URI correct after adding UIDVALIDITY w/ `/' separator");
+
+$uri = PublicInbox::URIimap->new('imap://u@example.com/a/b;UIDVALIDITY=3');
+is($uri->uidvalidity, 3, "UIDVALIDITY w/ `/' separator");
+is($uri->mailbox, 'a/b', "mailbox w/ `/' separator + UIDVALIDITY");
+is($uri->uidvalidity(4), 4, "UIDVALIDITY set w/ `/' separator");
+is($$uri, 'imap://u@example.com/a/b;UIDVALIDITY=4',
+ "URI correct after replacing UIDVALIDITY w/ `/' separator");
+is($uri->uid(5), 5, "set /;UID= w/ `/' separator");
+
+$uri = PublicInbox::URIimap->new('imap://u@example.com/a/b/;UID=9');
+is($uri->uid, 9, "UID read with `/' separator w/o UIDVALIDITY");
+is($uri->uid(8), 8, "UID set with `/' separator w/o UIDVALIDITY");
+is($$uri, 'imap://u@example.com/a/b/;UID=8',
+ "URI correct after replacing UID w/ `/' separator");
done_testing;