Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
diff --git a/lib/MojoMojo/Schema/Result/Page.pm b/lib/MojoMojo/Schema/Result/Page.pm
index 102844e..2bc94db 100644
--- a/lib/MojoMojo/Schema/Result/Page.pm
+++ b/lib/MojoMojo/Schema/Result/Page.pm
@@ -6,7 +6,7 @@ use Carp qw/croak/;
use base qw/MojoMojo::Schema::Base::Result/;
-__PACKAGE__->load_components( "PK::Auto", "Core" );
+__PACKAGE__->load_components( "PK::Auto", "UTF8Columns", "Core");
__PACKAGE__->table("page");
__PACKAGE__->add_columns(
"id",
@@ -29,6 +29,7 @@ __PACKAGE__->add_columns(
{ data_type => "INTEGER", is_nullable => 1, size => undef },
);
__PACKAGE__->set_primary_key("id");
+__PACKAGE__->utf8_columns("name", "name_orig");
__PACKAGE__->add_unique_constraint( "page_unique_child_index", [ "parent", "name" ] );
__PACKAGE__->has_many( "wantedpages", "MojoMojo::Schema::Result::WantedPage", { "foreign.from_page" => "self.id" }, );
__PACKAGE__->belongs_to( "parent", "MojoMojo::Schema::Result::Page", { id => "parent" } );
diff --git a/lib/MojoMojo/Schema/ResultSet/Page.pm b/lib/MojoMojo/Schema/ResultSet/Page.pm
index 2045540..29a2547 100644
--- a/lib/MojoMojo/Schema/ResultSet/Page.pm
+++ b/lib/MojoMojo/Schema/ResultSet/Page.pm
@@ -3,6 +3,8 @@ package MojoMojo::Schema::ResultSet::Page;
use strict;
use warnings;
use base qw/MojoMojo::Schema::Base::ResultSet/;
+use Encode ();
+use URI::Escape ();
=head1 NAME
@@ -162,7 +164,10 @@ sub normalize_name {
my $name = $name_orig;
$name =~ s/\s+/_/g;
$name = lc($name);
- return ( $name_orig, $name );
+ return (
+ Encode::decode_utf8(URI::Escape::uri_unescape($name_orig)),
+ Encode::decode_utf8(URI::Escape::uri_unescape($name)),
+ );
}
=item resolve_path <%args>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment