Give priority to the "new style" of news links over the old
authorMagnus Hagander <magnus@hagander.net>
Sun, 6 Feb 2022 12:37:31 +0000 (13:37 +0100)
committerMagnus Hagander <magnus@hagander.net>
Sun, 6 Feb 2022 12:39:55 +0000 (13:39 +0100)
This affects how we redirect news when tehre's what looks like an "id"
number both before and after. For example, the link:

2016-08-11-security-update-release-1688

would previously detect the id as 2017 and redirect to that article,
which is obviously wrong.

This changes the order so that id-at-the-end is checked first. This
instead gives problems for urls that *end* in a year (or other things
that looks like an id).

This is not ideal, but it's better than before because at least now the
links that are being generated *now* are handled the correct way.

pgweb/urls.py

index 78b61cee98c588307ff4a3d24f2441b3770dd34e..f349f0a147fabd1e6654e645f4824eec3259aaea 100644 (file)
@@ -35,8 +35,8 @@ urlpatterns = [
 
     url(r'^about/$', pgweb.core.views.about),
     url(r'^about/newsarchive/(?P<tag>[^/]*/)?(?P<paginator>[0-9]{8}/)?$', pgweb.news.views.archive),
-    url(r'^about/news/(?P<itemid>\d+)(?P<slug>-.*)?/$', pgweb.news.views.item),
     url(r'^about/news/(?P<slug>[^/]+)-(?P<itemid>\d+)/$', pgweb.news.views.item),
+    url(r'^about/news/(?P<itemid>\d+)(?P<slug>-.*)?/$', pgweb.news.views.item),
     url(r'^about/news/taglist.json/$', pgweb.news.views.taglist_json),
     url(r'^about/events/$', pgweb.events.views.main),
     url(r'^about/eventarchive/$', pgweb.events.views.archive),