weirdgloop / mediawiki-extensions-SearchDigest

Displays the most popular failed wiki searches in a special page, Special:SearchDigest.
GNU General Public License v3.0
1 stars 7 forks source link

Ensure alpha chars following first colon in page title are uppercase #13

Closed 1bakedpotato closed 3 months ago

1bakedpotato commented 3 months ago

As referenced in a message in #wiki-tech on the RS Wikis Discord, creating pages via the API with lowercase characters following the first colon in a page title can be problematic. It's difficult to navigate to them, view their history, edit them, or even delete them because MediaWiki tries its best to automatically convert such characters to uppercase.

Since a search for such a (malformed?) title, such as RuneScape:user help will instead be interpreted as "RuneScape:User help", it seems better to ensure these redirects are created with the much more accessible uppercase transformation already applied.

jayktaylor commented 3 months ago

Hey, thanks! Good idea, but I think it'd be better to use MediaWiki's built in title normalisation functionality in the mw.Title core module:

mw.Title.newFromUserInput('dragon_dagger').getPrefixedText()
// Dragon dagger

mw.Title.newFromUserInput('RuneScape:user help').getPrefixedText()
// RuneScape:User help

mw.Title.newFromUserInput('runescape:user help').getPrefixedText()
// RuneScape:User help

The only thing to be aware of with this approach is that we'll need to handle the part before and after the URL fragment (if one exists) separately, because this won't work:

mw.Title.newFromUserInput('dragon_dagger#test').getPrefixedText()
// Dragon dagger-test