Add tests for PageTitle (#2624)

This commit is contained in:
Adam Jones 2019-03-17 05:52:37 +00:00 committed by Vivek Maskara
parent cfade144d9
commit d719a4a9d4
2 changed files with 55 additions and 28 deletions

View file

@ -14,11 +14,9 @@ public class PageTitle {
public PageTitle(@NonNull String prefixedText) {
String[] segments = prefixedText.trim().replace(" ", "_").split(":", 2);
// canonicalize and capitalize page title as done by MediaWiki
// Canonicalize and capitalize page title and namespace (if present)
if (segments.length == 2) {
// TODO: canonicalize and capitalize namespace as well
// see https://www.mediawiki.org/wiki/Manual:Title.php#Canonical_forms
namespace = segments[0];
namespace = Utils.capitalize(segments[0]);
titleKey = Utils.capitalize(segments[1]);
} else {
namespace = "";