Ticket #415 (closed Bug: fixed)

Opened 10 months ago

Last modified 10 months ago

Config::set routes

Reported by: stach Owned by: Geert
Priority: minor Milestone: 2.1.2
Component: Core Version: SVN HEAD
Keywords: config set routes regex Cc:

Description

My sugestion is use one dot (first one), because I think that every next dots will make somethink like below:

Config::set('routes.news[\d]/(.+)', "news/$2");

and effect:

array
  '_allowed' => string '-a-z 0-9~%.,:_' (length=14)
  '_default' => string 'front' (length=5)
  'news[\d]/(' => 
    array
      '+)' => string 'news/$2' (length=7)

Change History

  Changed 10 months ago by Shadowhand

  • keywords config set routes regex added; config, set, routes, regexp removed
  • status changed from new to assigned

  Changed 10 months ago by Shadowhand

  • status changed from assigned to closed
  • resolution set to fixed

Fixed in r2076.

follow-up: ↓ 4   Changed 10 months ago by Shadowhand

Usage:

Config::set('routes.{news[\d]/(.+)}', 'news/$1');

in reply to: ↑ 3   Changed 10 months ago by Geert

  • status changed from closed to reopened
  • resolution deleted

What a mess indeed, Woody. ;)

The worst thing is that that ugly hack doesn't even work correctly. As soon as you have a regex that contains "}." as part of the regex, it falls apart completely.

Example: Config::set('routes.{routes.news\d{3}.+}', 'failed');

As far as I see, there is absolutely no way to tell when "}." is part of the regex and when it is part of the config key wrapper. Regular expressions can contain anything. So, parsing regex with regex accurately, is impossible.

  Changed 10 months ago by Geert

  • owner changed from Shadowhand to Geert
  • status changed from reopened to new

  Changed 10 months ago by Geert

  • status changed from new to closed
  • resolution set to fixed

Fixed again in r2080. Route regexes can now contain anything.

Example: Config::set('routes.news\d{3}.+', 'yay!');

As you can see, you must not add { } around your regex anymore. This will make things work out of the box. As a trade-off, the routes config does not allow for sub keys anymore.

  Changed 10 months ago by Shadowhand

Thanks Geert. :)

Note: See TracTickets for help on using tickets.