summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2012-07-17 21:35:58 -0500
committerJesse Luehrs <doy@tozt.net>2012-07-17 21:35:58 -0500
commitfed9bc157ca3e60a06be9541dbdb0188f31f3d5f (patch)
tree7bf4d71306a016220d9b86d38b7f11f3cecb1dd3 /lib
parent505e602c31196f1f2f7ed6b5d986b18957d511e4 (diff)
downloadweb-request-fed9bc157ca3e60a06be9541dbdb0188f31f3d5f.tar.gz
web-request-fed9bc157ca3e60a06be9541dbdb0188f31f3d5f.zip
finish implementation of ::Upload
Diffstat (limited to 'lib')
-rw-r--r--lib/Web/Request/Upload.pm22
1 files changed, 19 insertions, 3 deletions
diff --git a/lib/Web/Request/Upload.pm b/lib/Web/Request/Upload.pm
index ff3592c..a3d8d77 100644
--- a/lib/Web/Request/Upload.pm
+++ b/lib/Web/Request/Upload.pm
@@ -24,9 +24,25 @@ has filename => (
isa => 'Str',
);
-sub basename {
- ...
-}
+# XXX Path::Class, and just make this a delegation?
+# would that work at all on win32?
+has basename => (
+ is => 'ro',
+ isa => 'Str',
+ lazy => 1,
+ default => sub {
+ my $self = shift;
+
+ require File::Spec::Unix;
+
+ my $basename = $self->{filename};
+ $basename =~ s{\\}{/}g;
+ $basename = (File::Spec::Unix->splitpath($basename))[2];
+ $basename =~ s{[^\w\.-]+}{_}g;
+
+ return $basename;
+ },
+);
__PACKAGE__->meta->make_immutable;
no Moose;