Code Monkey home page Code Monkey logo

Comments (4)

bramus avatar bramus commented on July 29, 2024

Hi Johan,

Thanks for pointing this out. The regex worked just fine, it was the post-processing (extraction of the callback parameters) that was messing things up. The fix has already been pushed; also included your test in the test suite :)

Regards,
Bram.

from router.

bramus avatar bramus commented on July 29, 2024

(The fix initially pushed introduced another bug, fixed it for good with 2d8107f

from router.

jbleuzen avatar jbleuzen commented on July 29, 2024

Ok, thanks for the quick-fix...
I will check that later :)

from router.

jbleuzen avatar jbleuzen commented on July 29, 2024

Hi,
I'm back I still have a problem with some matching...

If I want to match all routes with pagination I'm using the following rule : "/(*.)/page([0-9]+)"

But it's not working as expected :

  • "/my-url/page3" matches returns ["my-url", 3]
  • "/my-url/somewhere/page4 returns ["my-url", 4]

Here is a test class that fail :

public function testDynamicRouteValidOrNot() {

  // Create Router
  $router = new \Bramus\Router\Router();
  $router->get('/(.*)/page([0-9]+)', function($place, $page) {
      echo 'Hello ' . $place . ' page : ' . $page;
      });

  // Test the /hello/bramus/page3 route
  ob_start();
  $_SERVER['REQUEST_URI'] = '/hello/bramus/page3';
  $router->run();
  $this->assertEquals('Hello hello/bramus page : 3', ob_get_contents());

  // Cleanup
  ob_end_clean();
}

It returns ["hello", 4].

from router.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.