Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6981513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:10:01+00:00 2026-05-27T18:10:01+00:00

First thing first, a simple route addition: # The order is as-is in my

  • 0

First thing first, a simple route addition:

# The order is as-is in my environment
Route::PATTERN('/^\/style\/(.*?)\/$/', 'style/[0].css');
Route::PATTERN('/^\/style\/(.*?)\/image-storage\/(.*?)\/$/', 'transformed/images/[1]');
Route::SIMPLE('/blog', 'parts/blog');

The routes are not sorted by priorities for now (that’s an option if nothing else can be done, but I’d like to avoid it), and active route is determined, routine is performed after a scan (foreach loop through routes added above in the same order):

foreach(self::$routes as $route){
// lookup active route
switch($route->type){
    case self::TYPE_SIMPLE:
        if($route->lookup === $_SERVER['REQUEST_URI']) self::$active = $route;
    break;
    case self::TYPE_PATTERN:
        if(preg_match_all($route->lookup, $_SERVER['REQUEST_URI'], $found)){
            // find all replaceable entries of route
            preg_match_all('/((?<=\[)\d(?=\]))/', $route->location, $replace);

            // remove first results
            $lookup = array_shift($found);
            $location = array_shift($replace);

            // make the actual location out of both
            foreach($replace[0] as $value)
                if(isset($found[$value]))
                    $route->location = str_replace('[' . $value . ']', $found[$value][0], $route->location);

            // this is active, cache it
            self::$active = $route;
        }
    break;
}
}
// I have left out the active route and routine parsing, because the problem is here at the
// case self::TYPE_PATTERN part

The thing here is that the second pattern route is matched by the first one. I could prevent this with a lookahead, but the routes will later become dynamic and nested, therefore unpredictable- lookaheads could/would fail.

I had an idea about length comparison of requests and lookups (the patterns), but that’s pretty darn unpredictable also.

So, the question, how could I avoid this collision?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T18:10:01+00:00Added an answer on May 27, 2026 at 6:10 pm

    Move the less general route to the top, above the other. Then only if that fails to match will the more general one be attempted:

    Route::PATTERN('/^\/style\/(.*?)\/image-storage\/(.*?)\/$/', 'transformed/images/[1]');
    Route::PATTERN('/^\/style\/(.*?)\/$/', 'style/[0].css');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Seems like a simple thing at first, but becoming a bit more complex than
First thing i want to say that it's not an easy question to explain,
The first thing that comes to my mind is to do a bunch of
I was just reading this line: The first thing the format() method does is
I'm just taking my first steps with Azure and the first thing I see
I have some jQuery/JS below. The first thing to run is the alert box
To begin with, I don't know the first thing about Python ... so I
I've just started learning MATLAB, and the first thing i tried is to plot
I am writing a web part against a list. The first thing I do
maven release:perform is failing to distribute via FTP. The first thing I checked is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.