|
No problem, now we can compare solutions match: new RegExp("^(https?://)?([^/]+\\.)?(artlibre\\.org/licence|creativecommons\\.org/licenses/)", "i"),
--> match: new RegExp("^(https?://)?([^/]+\\.)?(artlibre\\.org/licence|creativecommons\\.org/(licenses|publicdomain)/)", "i"),
and url = url.replace(/^http:\/\/creativecommons\.org\/licenses\/(.+)\/((legalcode|deed)((\.|-)[A-Za-z_]+)?)?/, "http://creativecommons.org/licenses/$1/"); --> url = url.replace(/^http:\/\/creativecommons\.org\/(licenses|publicdomain\/zero)\/(.+)\/((legalcode|deed)((\.|-)[A-Za-z_]+)?)?/, "http://creativecommons.org/$1/$2/"); What was your approach? As for Mine is exactly the same, except without the zero added there, just (licenses|publicdomain) - since if there are other publicdomain ones now or in the future, I'd expect us to want to support them too. And yeah, the other one is easy to solve dirtily, but of course url = url.replace(/^(?:https?:\/\/)?(?:[^\/]+\.)?creativecommons\.org\/(.+)([^\/])$/, "http://creativecommons.org/$1$2/"); means that if the user enters a space or whatever, a new slash will be added, which is horrible Hmm, but does your code correctly normalize (= strip) "/legalcode" then from the URL? I had to include the "zero" because of that... url = url.replace(/^http:\/\/creativecommons\.org\/(licenses|publicdomain)\/(.+)\/((legalcode|deed)((\.|-)[A-Za-z_]+)?)?/, "http://creativecommons.org/$1/$2/"); seems to work OK for me in the sandbox, including stripping legalcode You are right |
||||||||||||||||||||||||||||||||||
Heh, modified the code for this and later realised you assigned yourself. Should I submit it or will you do a patch that does both this and
MBS-4810in one go?