brendanheywood / moodle-local_cleanurls

Lets drag Moodle's url structure into this century...
37 stars 24 forks source link

Progressively analyse URL like a state machine instead of applying several regexes until getting a match. #61

Open roperto opened 7 years ago

roperto commented 7 years ago

This refactor will allow to implement the ideas described in #59 , the current test cases should all still pass.

Here is a list of current mappings in the current order:

/local/cleanurls/tests/bar # unclean_test_url
/local/cleanurls/tests/webcheck # unclean_test_url
^/course/([^/]+)/?(.*)$ # unclean_course_format
^/course/(.+)/user/(.+)$ # unclean_user_in_course
^/course/(.+)/user/?$ # unclean_course_users
^/user/(\w+)/(discussions)$ # unclean_user_in_forum
^/user/(.+)$ # unclean_user_profile_or_in_course
^/course/(.+)/(\w+)/(\d+)(-.*)?$ # unclean_course_module_view
^/course/(.+)/(\w+)/?$ # unclean_course_modules
^/course/([^/]+)/?$ # unclean_course
^/category(/.*-(\d+))?$ # unclean_category

With that we can clearly see that from the initial state, it will change to 'self test', 'category', 'course', 'user' and most of the work will be done at 'course' level.

roperto commented 7 years ago

cleanurl