brendanheywood / moodle-local_cleanurls

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

Issues with clean urls vs cleanest urls, should get instant replaceState #108

Open brendanheywood opened 6 years ago

brendanheywood commented 6 years ago

So currently the existing logic for clean urls is they are clean, or they are not.

But we now have the situtions there where are multiple verisons of a url all of which work, but one is considered cleaner, or canonical. ie:

Module id based url: https://u.catalyst-au.net/course/COMP100/module-1/16-test-unboxpage

Custom stub based url: https://u.catalyst-au.net/course/COMP100/module-1/test/etst

On unclean pages we detect that a page could be clean, and then use html5 replace state to fix the url. We also need to do it this case.

if (element.getAttribute('href').charAt(0) == '#') {
--
  | element.href = 'https://u-cqu-mba.catalyst-au.net/course/COMP100/module-1/test/etst' + element.getAttribute('href');
  | }
roperto commented 6 years ago

@brendanheywood

When using a format that renders the default module subpath, it will try to first use the custom path then the id-name version if no custom path. From my understanding, we don't have two URLs and one of them is "better" but we have only the cleaned and uncleaned.

I probably misunderstood something, but I need an example of what is wrong or could be improved.

I understand the second part of the replacestate, where we are losing the anchor # part of the URL that needs to be fixed, but I don't really see how an URL coming through the router (not legacy URL) can have a better version, at least not at this stage.

For the legacy ones, we will apply the uncleaning and it will give the cleaned version (which is already doing) -- it does not give a list of options where we have to choose the best one.

Again, I know I am probably misunderstanding something so let's talk about that when you have some time.

brendanheywood commented 6 years ago

Pretty sure we covered this 1-1 but re-iterating:

if you have an activity with no custom slug, then it has url A. If you then add a custom stub it has url B.

B is 'cleaner' than A and should be considered canonical. But A should still continue to work.

Short story is that any cleanable page (and only cleanable pages) should always server a canonical url