Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#1325] let register_string redirect pagename/ to pagename #1974

Merged
merged 1 commit into from Feb 12, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 15 additions & 9 deletions cgi-bin/DW/Routing.pm
Expand Up @@ -398,18 +398,24 @@ sub register_string {
$string_choices{'app' . $string} = $hash if $hash->{app};
$string_choices{'user' . $string} = $hash if $hash->{user};

my %redirect_opts = (
app => $hash->{app},
user => $hash->{user},
formats => $hash->{formats},
format => $hash->{format},
no_redirects => 1,
keep_args => 1,
);

if ( $string =~ m!(^(.*)/)index$! && ! exists $opts{no_redirects} ) {
my %opts = (
app => $hash->{app},
user => $hash->{user},
formats => $hash->{formats},
format => $hash->{format},
no_redirects => 1,
keep_args => 1,
);
$class->register_redirect( $2, $1, %opts ) if $2;
$class->register_redirect( $2, $1, %redirect_opts ) if $2;
$string_choices{'app' . $1} = $hash if $hash->{app};
$string_choices{'user' . $1} = $hash if $hash->{user};

} elsif ( ! exists $opts{no_redirects} ) {
# for all other (non-index) pages, redirect page/ to page
$class->register_redirect( "$string/", $string, %redirect_opts );

}
}

Expand Down