Skip to content

Bug(s) in url_for? #1781

Open
Open
@reneeb

Description

@reneeb
  • Mojolicious version: 9.17
  • Perl version: 5.26.1
  • Operating system: Ubuntu

Steps to reproduce the behavior

#!/usr/bin/perl

use Mojolicious::Lite -strict;

under '/admin/:area' => [ area => [qw/test hallo/] ] => { area => 'hallo' };

get( '/:tag' )->name('single_tag');

say app->url_for( 'single_tag', tag => 'test', area => 'hallo' );
say app->url_for( 'single_tag', tag => 'test', area => 'bug' );
say app->url_for( 'single_tag', tag => 'test', area => 'world' );
say app->url_for( 'single_tag', tag => 'test' );
say app->url_for( 'single_tag', tag => 'test', format => 'json' );

Prints

❯ perl url_for.pl 
/admin/test
/admin/bug/test
/admin/world/test
/admin/test
/admin/hallo/test.json

Expected behavior

I would expect that the area placeholder is replaced with hallo in the first and fourth call.

And as content negotiation via file suffix was disabled by default in 9.11 and 9.17 added ?_format=*, I would expect url_for to return /admin/hallo/test?_format=json in the last call.

This is all done in https://github.com/mojolicious/mojo/blob/main/lib/Mojolicious/Routes/Pattern.pm (sub render)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions