Skip to content

Commit

Permalink
let Mojolicious::Static handle UTF-8 file names too
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Oct 5, 2017
1 parent 0c47879 commit 9c5f215
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions Changes
@@ -1,6 +1,7 @@

7.47 2017-10-05
- Added multipart content generator to Mojo::UserAgent::Transactor.
- Improved Mojolicious::Static with support for UTF-8 file names.
- Fixed a bug in Mojo::File where parts of a path could get accidentally
upgraded from bytes to characters.

Expand Down
7 changes: 4 additions & 3 deletions lib/Mojolicious/Static.pm
Expand Up @@ -7,7 +7,7 @@ use Mojo::Date;
use Mojo::File 'path';
use Mojo::Home;
use Mojo::Loader 'data_section';
use Mojo::Util 'md5_sum';
use Mojo::Util qw(encode md5_sum);

# Bundled files
my $PUBLIC = Mojo::Home->new(Mojo::Home->new->mojo_lib_dir)
Expand Down Expand Up @@ -43,9 +43,10 @@ sub file {
my ($self, $rel) = @_;

# Search all paths
my @parts = map { encode 'UTF-8', $_ } split '/', $rel;
for my $path (@{$self->paths}) {
my $asset = $self->_get_file(path($path, split('/', $rel))->to_string);
return $asset if $asset;
next unless my $asset = $self->_get_file(path($path, @parts)->to_string);
return $asset;
}

# Search DATA
Expand Down

0 comments on commit 9c5f215

Please sign in to comment.