2 * @author Neil Kandalgaonkar, 2010
7 * Parse titles into an object structure. Note that when using the constructor
8 * directly, passing invalid titles will result in an exception. Use #newFromText to use the
9 * logic directly and get null for invalid titles which is easier to work with.
11 * Note that in the constructor and #newFromText method, `namespace` is the **default** namespace
12 * only, and can be overridden by a namespace prefix in `title`. If you do not want this behavior,
13 * use #makeTitle. Compare:
15 * new mw.Title( 'Foo', NS_TEMPLATE ).getPrefixedText(); // => 'Template:Foo'
16 * mw.Title.newFromText( 'Foo', NS_TEMPLATE ).getPrefixedText(); // => 'Template:Foo'
17 * mw.Title.makeTitle( NS_TEMPLATE, 'Foo' ).getPrefixedText(); // => 'Template:Foo'
19 * new mw.Title( 'Category:Foo', NS_TEMPLATE ).getPrefixedText(); // => 'Category:Foo'
20 * mw.Title.newFromText( 'Category:Foo', NS_TEMPLATE ).getPrefixedText(); // => 'Category:Foo'
21 * mw.Title.makeTitle( NS_TEMPLATE, 'Category:Foo' ).getPrefixedText(); // => 'Template:Category:Foo'
23 * new mw.Title( 'Template:Foo', NS_TEMPLATE ).getPrefixedText(); // => 'Template:Foo'
24 * mw.Title.newFromText( 'Template:Foo', NS_TEMPLATE ).getPrefixedText(); // => 'Template:Foo'
25 * mw.Title.makeTitle( NS_TEMPLATE, 'Template:Foo' ).getPrefixedText(); // => 'Template:Template:Foo'
33 mwString
= require( 'mediawiki.String' ),
35 toUpperMapping
= require( './phpCharToUpper.json' ),
37 namespaceIds
= mw
.config
.get( 'wgNamespaceIds' ),
44 NS_MAIN
= namespaceIds
[ '' ],
51 NS_TALK
= namespaceIds
.talk
,
56 * @property NS_SPECIAL
58 NS_SPECIAL
= namespaceIds
.special
,
65 NS_MEDIA
= namespaceIds
.media
,
72 NS_FILE
= namespaceIds
.file
,
77 * @property FILENAME_MAX_BYTES
79 FILENAME_MAX_BYTES
= 240,
84 * @property TITLE_MAX_BYTES
86 TITLE_MAX_BYTES
= 255,
89 * Get the namespace id from a namespace name (either from the localized, canonical or alias
92 * Example: On a German wiki this would return 6 for any of 'File', 'Datei', 'Image' or
97 * @method getNsIdByName
98 * @param {string} ns Namespace name (case insensitive, leading/trailing space ignored)
99 * @return {number|boolean} Namespace id or boolean false
101 getNsIdByName = function ( ns
) {
104 // Don't cast non-strings to strings, because null or undefined should not result in
105 // returning the id of a potential namespace called "Null:" (e.g. on null.example.org/wiki)
106 // Also, toLowerCase throws exception on null/undefined, because it is a String method.
107 if ( typeof ns
!== 'string' ) {
110 // TODO: Should just use local var namespaceIds here but it
111 // breaks test which modify the config
112 id
= mw
.config
.get( 'wgNamespaceIds' )[ ns
.toLowerCase() ];
113 if ( id
=== undefined ) {
121 * @method getNamespacePrefix_
122 * @param {number} namespace
125 getNamespacePrefix = function ( namespace ) {
126 return namespace === NS_MAIN
?
128 ( mw
.config
.get( 'wgFormattedNamespaces' )[ namespace ].replace( / /g
, '_' ) + ':' );
131 rUnderscoreTrim
= /^_+|_+$/g,
133 rSplit
= /^(.+?)_*:_*(.*)$/,
135 // See MediaWikiTitleCodec.php#getTitleInvalidRegex
136 rInvalid
= new RegExp(
137 '[^' + mw
.config
.get( 'wgLegalTitleChars' ) + ']' +
138 // URL percent encoding sequences interfere with the ability
139 // to round-trip titles -- you can't link to them consistently.
141 // XML/HTML character references produce similar issues.
142 '|&[A-Za-z0-9\u0080-\uFFFF]+;' +
147 // From MediaWikiTitleCodec::splitTitleString() in PHP
148 // Note that this is not equivalent to /\s/, e.g. underscore is included, tab is not included.
149 rWhitespace
= /[ _\u00A0\u1680\u180E\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]+/g,
151 // From MediaWikiTitleCodec::splitTitleString() in PHP
152 rUnicodeBidi
= /[\u200E\u200F\u202A-\u202E]/g,
155 * Slightly modified from Flinfo. Credit goes to Lupo and Flominator.
158 * @property sanitationRules
167 // control characters
169 // eslint-disable-next-line no-control-regex
170 pattern
: /[\x00-\x1f\x7f]/g,
174 // URL encoding (possibly)
176 pattern
: /%([0-9A-Fa-f]{2})/g,
180 // HTML-character-entities
182 pattern
: /&(([A-Za-z0-9\x80-\xff]+|#[0-9]+|#x[0-9A-Fa-f]+);)/g,
186 // slash, colon (not supported by file systems like NTFS/Windows, Mac OS 9 [:], ext4 [/])
188 pattern
: new RegExp( '[' + mw
.config
.get( 'wgIllegalFileChars', '' ) + ']', 'g' ),
192 // brackets, greater than
198 // brackets, lower than
204 // everything that wasn't covered yet
206 pattern
: new RegExp( rInvalid
.source
, 'g' ),
210 // directory structures
212 pattern
: /^(\.|\.\.|\.\/.*|\.\.\/.*|.*\/\.\/.*|.*\/\.\.\/.*|.*\/\.|.*\/\.\.)$/g,
219 * Internal helper for #constructor and #newFromText.
221 * Based on Title.php#secureAndSplit
226 * @param {string} title
227 * @param {number} [defaultNamespace=NS_MAIN]
228 * @return {Object|boolean}
230 parse = function ( title
, defaultNamespace
) {
231 var namespace, m
, id
, i
, fragment
, ext
;
233 namespace = defaultNamespace
=== undefined ? NS_MAIN
: defaultNamespace
;
236 // Strip Unicode bidi override characters
237 .replace( rUnicodeBidi
, '' )
238 // Normalise whitespace to underscores and remove duplicates
239 .replace( rWhitespace
, '_' )
241 .replace( rUnderscoreTrim
, '' );
243 // Process initial colon
244 if ( title
!== '' && title
[ 0 ] === ':' ) {
245 // Initial colon means main namespace instead of specified default
251 .replace( rUnderscoreTrim
, '' );
254 if ( title
=== '' ) {
258 // Process namespace prefix (if any)
259 m
= title
.match( rSplit
);
261 id
= getNsIdByName( m
[ 1 ] );
262 if ( id
!== false ) {
263 // Ordinary namespace
267 // For Talk:X pages, make sure X has no "namespace" prefix
268 if ( namespace === NS_TALK
&& ( m
= title
.match( rSplit
) ) ) {
269 // Disallow titles like Talk:File:x (subject should roundtrip: talk:file:x -> file:x -> file_talk:x)
270 if ( getNsIdByName( m
[ 1 ] ) !== false ) {
278 i
= title
.indexOf( '#' );
283 // Get segment starting after the hash
286 // NB: Must not be trimmed ("Example#_foo" is not the same as "Example#foo")
287 .replace( /_
/g
, ' ' );
292 // Trim underscores, again (strips "_" from "bar" in "Foo_bar_#quux")
293 .replace( rUnderscoreTrim
, '' );
296 // Reject illegal characters
297 if ( title
.match( rInvalid
) ) {
301 // Disallow titles that browsers or servers might resolve as directory navigation
303 title
.indexOf( '.' ) !== -1 && (
304 title
=== '.' || title
=== '..' ||
305 title
.indexOf( './' ) === 0 ||
306 title
.indexOf( '../' ) === 0 ||
307 title
.indexOf( '/./' ) !== -1 ||
308 title
.indexOf( '/../' ) !== -1 ||
309 title
.slice( -2 ) === '/.' ||
310 title
.slice( -3 ) === '/..'
316 // Disallow magic tilde sequence
317 if ( title
.indexOf( '~~~' ) !== -1 ) {
321 // Disallow titles exceeding the TITLE_MAX_BYTES byte size limit (size of underlying database field)
322 // Except for special pages, e.g. [[Special:Block/Long name]]
323 // Note: The PHP implementation also asserts that even in NS_SPECIAL, the title should
324 // be less than 512 bytes.
325 if ( namespace !== NS_SPECIAL
&& mwString
.byteLength( title
) > TITLE_MAX_BYTES
) {
329 // Can't make a link to a namespace alone.
330 if ( title
=== '' && namespace !== NS_MAIN
) {
334 // Any remaining initial :s are illegal.
335 if ( title
[ 0 ] === ':' ) {
339 // For backwards-compatibility with old mw.Title, we separate the extension from the
340 // rest of the title.
341 i
= title
.lastIndexOf( '.' );
342 if ( i
=== -1 || title
.length
<= i
+ 1 ) {
343 // Extensions are the non-empty segment after the last dot
346 ext
= title
.slice( i
+ 1 );
347 title
= title
.slice( 0, i
);
351 namespace: namespace,
359 * Convert db-key to readable text.
367 text = function ( s
) {
368 return s
.replace( /_
/g
, ' ' );
372 * Sanitizes a string based on a rule set and a filter
378 * @param {Array} filter
381 sanitize = function ( s
, filter
) {
382 var i
, ruleLength
, rule
, m
, filterLength
,
383 rules
= sanitationRules
;
385 for ( i
= 0, ruleLength
= rules
.length
; i
< ruleLength
; ++i
) {
387 for ( m
= 0, filterLength
= filter
.length
; m
< filterLength
; ++m
) {
388 if ( rule
[ filter
[ m
] ] ) {
389 s
= s
.replace( rule
.pattern
, rule
.replace
);
397 * Cuts a string to a specific byte length, assuming UTF-8
398 * or less, if the last character is a multi-byte one
402 * @method trimToByteLength
404 * @param {number} length
407 trimToByteLength = function ( s
, length
) {
408 return mwString
.trimByteLength( '', s
, length
).newVal
;
412 * Cuts a file name to a specific byte length
416 * @method trimFileNameToByteLength
417 * @param {string} name without extension
418 * @param {string} extension file extension
419 * @return {string} The full name, including extension
421 trimFileNameToByteLength = function ( name
, extension
) {
422 // There is a special byte limit for file names and ... remember the dot
423 return trimToByteLength( name
, FILENAME_MAX_BYTES
- extension
.length
- 1 ) + '.' + extension
;
427 * @method constructor
428 * @param {string} title Title of the page. If no second argument given,
429 * this will be searched for a namespace
430 * @param {number} [namespace=NS_MAIN] If given, will used as default namespace for the given title
431 * @throws {Error} When the title is invalid
433 function Title( title
, namespace ) {
434 var parsed
= parse( title
, namespace );
436 throw new Error( 'Unable to parse title' );
439 this.namespace = parsed
.namespace;
440 this.title
= parsed
.title
;
441 this.ext
= parsed
.ext
;
442 this.fragment
= parsed
.fragment
;
448 * Constructor for Title objects with a null return instead of an exception for invalid titles.
450 * Note that `namespace` is the **default** namespace only, and can be overridden by a namespace
451 * prefix in `title`. If you do not want this behavior, use #makeTitle. See #constructor for
455 * @param {string} title
456 * @param {number} [namespace=NS_MAIN] Default namespace
457 * @return {mw.Title|null} A valid Title object or null if the title is invalid
459 Title
.newFromText = function ( title
, namespace ) {
460 var t
, parsed
= parse( title
, namespace );
465 t
= Object
.create( Title
.prototype );
466 t
.namespace = parsed
.namespace;
467 t
.title
= parsed
.title
;
469 t
.fragment
= parsed
.fragment
;
475 * Constructor for Title objects with predefined namespace.
477 * Unlike #newFromText or #constructor, this function doesn't allow the given `namespace` to be
478 * overridden by a namespace prefix in `title`. See #constructor for details about this behavior.
480 * The single exception to this is when `namespace` is 0, indicating the main namespace. The
481 * function behaves like #newFromText in that case.
484 * @param {number} namespace Namespace to use for the title
485 * @param {string} title
486 * @return {mw.Title|null} A valid Title object or null if the title is invalid
488 Title
.makeTitle = function ( namespace, title
) {
489 return mw
.Title
.newFromText( getNamespacePrefix( namespace ) + title
);
493 * Constructor for Title objects from user input altering that input to
494 * produce a title that MediaWiki will accept as legal
497 * @param {string} title
498 * @param {number|Object} [defaultNamespaceOrOptions=NS_MAIN]
499 * If given, will used as default namespace for the given title.
500 * This method can also be called with two arguments, in which case
501 * this becomes options (see below).
502 * @param {Object} [options] additional options
503 * @param {boolean} [options.forUploading=true]
504 * Makes sure that a file is uploadable under the title returned.
505 * There are pages in the file namespace under which file upload is impossible.
506 * Automatically assumed if the title is created in the Media namespace.
507 * @return {mw.Title|null} A valid Title object or null if the input cannot be turned into a valid title
509 Title
.newFromUserInput = function ( title
, defaultNamespaceOrOptions
, options
) {
510 var namespace, m
, id
, ext
, lastDot
,
513 // defaultNamespace is optional; check whether options moves up
514 if ( arguments
.length
< 3 && typeof defaultNamespace
=== 'object' ) {
515 options
= defaultNamespaceOrOptions
;
517 defaultNamespace
= defaultNamespaceOrOptions
;
520 // merge options into defaults
521 options
= $.extend( {
525 namespace = defaultNamespace
=== undefined ? NS_MAIN
: defaultNamespace
;
527 // Normalise additional whitespace
528 title
= title
.replace( /\s/g, ' ' ).trim();
530 // Process initial colon
531 if ( title
!== '' && title
[ 0 ] === ':' ) {
532 // Initial colon means main namespace instead of specified default
538 .replace( rUnderscoreTrim
, '' );
541 // Process namespace prefix (if any)
542 m
= title
.match( rSplit
);
544 id
= getNsIdByName( m
[ 1 ] );
545 if ( id
!== false ) {
546 // Ordinary namespace
553 namespace === NS_MEDIA
||
554 ( options
.forUploading
&& ( namespace === NS_FILE
) )
556 title
= sanitize( title
, [ 'generalRule', 'fileRule' ] );
558 // Operate on the file extension
559 // Although it is possible having spaces between the name and the ".ext" this isn't nice for
560 // operating systems hiding file extensions -> strip them later on
561 lastDot
= title
.lastIndexOf( '.' );
563 // No or empty file extension
564 if ( lastDot
=== -1 || lastDot
>= title
.length
- 1 ) {
568 // Get the last part, which is supposed to be the file extension
569 ext
= title
.slice( lastDot
+ 1 );
571 // Remove whitespace of the name part (that without extension)
572 title
= title
.slice( 0, lastDot
).trim();
574 // Cut, if too long and append file extension
575 title
= trimFileNameToByteLength( title
, ext
);
577 title
= sanitize( title
, [ 'generalRule' ] );
579 // Cut titles exceeding the TITLE_MAX_BYTES byte size limit
580 // (size of underlying database field)
581 if ( namespace !== NS_SPECIAL
) {
582 title
= trimToByteLength( title
, TITLE_MAX_BYTES
);
586 // Any remaining initial :s are illegal.
587 title
= title
.replace( /^:+/, '' );
589 return Title
.newFromText( title
, namespace );
593 * Sanitizes a file name as supplied by the user, originating in the user's file system
594 * so it is most likely a valid MediaWiki title and file name after processing.
595 * Returns null on fatal errors.
598 * @param {string} uncleanName The unclean file name including file extension but
600 * @return {mw.Title|null} A valid Title object or null if the title is invalid
602 Title
.newFromFileName = function ( uncleanName
) {
604 return Title
.newFromUserInput( 'File:' + uncleanName
, {
610 * Get the file title from an image element
612 * var title = mw.Title.newFromImg( $( 'img:first' ) );
615 * @param {HTMLElement|jQuery} img The image to use as a base
616 * @return {mw.Title|null} The file title or null if unsuccessful
618 Title
.newFromImg = function ( img
) {
619 var matches
, i
, regex
, src
, decodedSrc
,
621 // thumb.php-generated thumbnails
622 thumbPhpRegex
= /thumb\.php/,
625 /\/[a-f0-9]\/[a-f0-9]{2}\/([^\s/]+)\/[^\s/]+-[^\s
/]*$/,
628 /\/[a-f0-9]\/[a-f0-9]{2}\/([^\s/]+)$/,
630 // Thumbnails in non-hashed upload directories
631 /\/([^\s/]+)\/[^\s/]+-(?:\1|thumbnail
)[^\s
/]*$/,
633 // Full-size images in non-hashed upload directories
637 recount
= regexes
.length
;
639 src
= img
.jquery
? img
[ 0 ].src
: img
.src
;
641 matches
= src
.match( thumbPhpRegex
);
644 return mw
.Title
.newFromText( 'File:' + mw
.util
.getParamValue( 'f', src
) );
647 decodedSrc
= decodeURIComponent( src
);
649 for ( i
= 0; i
< recount
; i
++ ) {
650 regex
= regexes
[ i
];
651 matches
= decodedSrc
.match( regex
);
653 if ( matches
&& matches
[ 1 ] ) {
654 return mw
.Title
.newFromText( 'File:' + matches
[ 1 ] );
662 * Check if a given namespace is a talk namespace
664 * See MWNamespace::isTalk in PHP
666 * @param {number} namespaceId Namespace ID
667 * @return {boolean} Namespace is a talk namespace
669 Title
.isTalkNamespace = function ( namespaceId
) {
670 return !!( namespaceId
> NS_MAIN
&& namespaceId
% 2 );
674 * Check if signature buttons should be shown in a given namespace
676 * See MWNamespace::wantSignatures in PHP
678 * @param {number} namespaceId Namespace ID
679 * @return {boolean} Namespace is a signature namespace
681 Title
.wantSignaturesNamespace = function ( namespaceId
) {
682 return Title
.isTalkNamespace( namespaceId
) ||
683 mw
.config
.get( 'wgExtraSignatureNamespaces' ).indexOf( namespaceId
) !== -1;
687 * Whether this title exists on the wiki.
690 * @param {string|mw.Title} title prefixed db-key name (string) or instance of Title
691 * @return {boolean|null} Boolean if the information is available, otherwise null
692 * @throws {Error} If title is not a string or mw.Title
694 Title
.exists = function ( title
) {
696 obj
= Title
.exist
.pages
;
698 if ( typeof title
=== 'string' ) {
699 match
= obj
[ title
];
700 } else if ( title
instanceof Title
) {
701 match
= obj
[ title
.toString() ];
703 throw new Error( 'mw.Title.exists: title must be a string or an instance of Title' );
706 if ( typeof match
!== 'boolean' ) {
714 * Store page existence
717 * @property {Object} exist
718 * @property {Object} exist.pages Keyed by title. Boolean true value indicates page does exist.
720 * @property {Function} exist.set The setter function.
722 * Example to declare existing titles:
724 * Title.exist.set( ['User:John_Doe', ...] );
726 * Example to declare titles nonexistent:
728 * Title.exist.set( ['File:Foo_bar.jpg', ...], false );
730 * @property {string|Array} exist.set.titles Title(s) in strict prefixedDb title form
731 * @property {boolean} [exist.set.state=true] State of the given titles
737 set: function ( titles
, state
) {
741 titles
= Array
.isArray( titles
) ? titles
: [ titles
];
742 state
= state
=== undefined ? true : !!state
;
744 for ( i
= 0, len
= titles
.length
; i
< len
; i
++ ) {
745 pages
[ titles
[ i
] ] = state
;
752 * Normalize a file extension to the common form, making it lowercase and checking some synonyms,
753 * and ensure it's clean. Extensions with non-alphanumeric characters will be discarded.
754 * Keep in sync with File::normalizeExtension() in PHP.
756 * @param {string} extension File extension (without the leading dot)
757 * @return {string} File extension in canonical form
759 Title
.normalizeExtension = function ( extension
) {
761 lower
= extension
.toLowerCase(),
769 if ( Object
.prototype.hasOwnProperty
.call( squish
, lower
) ) {
770 return squish
[ lower
];
771 } else if ( /^[0-9a-z]+$/.test( lower
) ) {
779 * PHP's strtoupper differs from String.toUpperCase in a number of cases (T147646).
781 * @param {string} chr Unicode character
782 * @return {string} Unicode character, in upper case, according to the same rules as in PHP
784 Title
.phpCharToUpper = function ( chr
) {
785 var mapped
= toUpperMapping
[ chr
];
786 return mapped
|| chr
.toUpperCase();
795 * Get the namespace number
797 * Example: 6 for "File:Example_image.svg".
801 getNamespaceId: function () {
802 return this.namespace;
806 * Get the namespace prefix (in the content language)
808 * Example: "File:" for "File:Example_image.svg".
809 * In #NS_MAIN this is '', otherwise namespace name plus ':'
813 getNamespacePrefix: function () {
814 return getNamespacePrefix( this.namespace );
818 * Get the page name without extension or namespace prefix
820 * Example: "Example_image" for "File:Example_image.svg".
822 * For the page title (full page name without namespace prefix), see #getMain.
826 getName: function () {
828 mw
.config
.get( 'wgCaseSensitiveNamespaces' ).indexOf( this.namespace ) !== -1 ||
833 return mw
.Title
.phpCharToUpper( this.title
[ 0 ] ) + this.title
.slice( 1 );
837 * Get the page name (transformed by #text)
839 * Example: "Example image" for "File:Example_image.svg".
841 * For the page title (full page name without namespace prefix), see #getMainText.
845 getNameText: function () {
846 return text( this.getName() );
850 * Get the extension of the page name (if any)
852 * @return {string|null} Name extension or null if there is none
854 getExtension: function () {
859 * Shortcut for appendable string to form the main page name.
861 * Returns a string like ".json", or "" if no extension.
865 getDotExtension: function () {
866 return this.ext
=== null ? '' : '.' + this.ext
;
870 * Get the main page name
872 * Example: "Example_image.svg" for "File:Example_image.svg".
876 getMain: function () {
877 return this.getName() + this.getDotExtension();
881 * Get the main page name (transformed by #text)
883 * Example: "Example image.svg" for "File:Example_image.svg".
887 getMainText: function () {
888 return text( this.getMain() );
892 * Get the full page name
894 * Example: "File:Example_image.svg".
895 * Most useful for API calls, anything that must identify the "title".
899 getPrefixedDb: function () {
900 return this.getNamespacePrefix() + this.getMain();
904 * Get the full page name (transformed by #text)
906 * Example: "File:Example image.svg" for "File:Example_image.svg".
910 getPrefixedText: function () {
911 return text( this.getPrefixedDb() );
915 * Get the page name relative to a namespace
919 * - "Foo:Bar" relative to the Foo namespace becomes "Bar".
920 * - "Bar" relative to any non-main namespace becomes ":Bar".
921 * - "Foo:Bar" relative to any namespace other than Foo stays "Foo:Bar".
923 * @param {number} namespace The namespace to be relative to
926 getRelativeText: function ( namespace ) {
927 if ( this.getNamespaceId() === namespace ) {
928 return this.getMainText();
929 } else if ( this.getNamespaceId() === NS_MAIN
) {
930 return ':' + this.getPrefixedText();
932 return this.getPrefixedText();
937 * Get the fragment (if any).
939 * Note that this method (by design) does not include the hash character and
940 * the value is not url encoded.
942 * @return {string|null}
944 getFragment: function () {
945 return this.fragment
;
949 * Get the URL to this title
951 * @see mw.util#getUrl
952 * @param {Object} [params] A mapping of query parameter names to values,
953 * e.g. `{ action: 'edit' }`.
956 getUrl: function ( params
) {
957 var fragment
= this.getFragment();
959 return mw
.util
.getUrl( this.toString() + '#' + fragment
, params
);
961 return mw
.util
.getUrl( this.toString(), params
);
966 * Check if the title is in a talk namespace
968 * @return {boolean} The title is in a talk namespace
970 isTalkPage: function () {
971 return Title
.isTalkNamespace( this.getNamespaceId() );
975 * Get the title for the associated talk page
977 * @return {mw.Title|null} The title for the associated talk page, null if not available
979 getTalkPage: function () {
980 if ( !this.canHaveTalkPage() ) {
983 return this.isTalkPage() ?
985 Title
.makeTitle( this.getNamespaceId() + 1, this.getMainText() );
989 * Get the title for the subject page of a talk page
991 * @return {mw.Title|null} The title for the subject page of a talk page, null if not available
993 getSubjectPage: function () {
994 return this.isTalkPage() ?
995 Title
.makeTitle( this.getNamespaceId() - 1, this.getMainText() ) :
1000 * Check the the title can have an associated talk page
1002 * @return {boolean} The title can have an associated talk page
1004 canHaveTalkPage: function () {
1005 return this.getNamespaceId() >= NS_MAIN
;
1009 * Whether this title exists on the wiki.
1011 * @see #static-method-exists
1012 * @return {boolean|null} Boolean if the information is available, otherwise null
1014 exists: function () {
1015 return Title
.exists( this );
1020 * @alias #getPrefixedDb
1023 Title
.prototype.toString
= Title
.prototype.getPrefixedDb
;
1026 * @alias #getPrefixedText
1029 Title
.prototype.toText
= Title
.prototype.getPrefixedText
;