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 namespaceIds
= mw
.config
.get( 'wgNamespaceIds' ),
42 NS_MAIN
= namespaceIds
[ '' ],
49 NS_TALK
= namespaceIds
.talk
,
54 * @property NS_SPECIAL
56 NS_SPECIAL
= namespaceIds
.special
,
63 NS_MEDIA
= namespaceIds
.media
,
70 NS_FILE
= namespaceIds
.file
,
75 * @property FILENAME_MAX_BYTES
77 FILENAME_MAX_BYTES
= 240,
82 * @property TITLE_MAX_BYTES
84 TITLE_MAX_BYTES
= 255,
87 * Get the namespace id from a namespace name (either from the localized, canonical or alias
90 * Example: On a German wiki this would return 6 for any of 'File', 'Datei', 'Image' or
95 * @method getNsIdByName
96 * @param {string} ns Namespace name (case insensitive, leading/trailing space ignored)
97 * @return {number|boolean} Namespace id or boolean false
99 getNsIdByName = function ( ns
) {
102 // Don't cast non-strings to strings, because null or undefined should not result in
103 // returning the id of a potential namespace called "Null:" (e.g. on null.example.org/wiki)
104 // Also, toLowerCase throws exception on null/undefined, because it is a String method.
105 if ( typeof ns
!== 'string' ) {
108 // TODO: Should just use local var namespaceIds here but it
109 // breaks test which modify the config
110 id
= mw
.config
.get( 'wgNamespaceIds' )[ ns
.toLowerCase() ];
111 if ( id
=== undefined ) {
119 * @method getNamespacePrefix_
120 * @param {number} namespace
123 getNamespacePrefix = function ( namespace ) {
124 return namespace === NS_MAIN
?
126 ( mw
.config
.get( 'wgFormattedNamespaces' )[ namespace ].replace( / /g
, '_' ) + ':' );
129 rUnderscoreTrim
= /^_+|_+$/g,
131 rSplit
= /^(.+?)_*:_*(.*)$/,
133 // See MediaWikiTitleCodec.php#getTitleInvalidRegex
134 rInvalid
= new RegExp(
135 '[^' + mw
.config
.get( 'wgLegalTitleChars' ) + ']' +
136 // URL percent encoding sequences interfere with the ability
137 // to round-trip titles -- you can't link to them consistently.
139 // XML/HTML character references produce similar issues.
140 '|&[\\dA-Za-z\u0080-\uFFFF]+;' +
145 // From MediaWikiTitleCodec::splitTitleString() in PHP
146 // Note that this is not equivalent to /\s/, e.g. underscore is included, tab is not included.
147 rWhitespace
= /[ _\u00A0\u1680\u180E\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]+/g,
149 // From MediaWikiTitleCodec::splitTitleString() in PHP
150 rUnicodeBidi
= /[\u200E\u200F\u202A-\u202E]+/g,
153 * Slightly modified from Flinfo. Credit goes to Lupo and Flominator.
156 * @property sanitationRules
165 // control characters
167 // eslint-disable-next-line no-control-regex
168 pattern
: /[\x00-\x1f\x7f]/g,
172 // URL encoding (possibly)
174 pattern
: /%([\dA-Fa-f]{2})/g,
178 // HTML-character-entities
180 pattern
: /&(([\dA-Za-z\x80-\xff]+|#\d+|#x[\dA-Fa-f]+);)/g,
184 // slash, colon (not supported by file systems like NTFS/Windows, Mac OS 9 [:], ext4 [/])
186 pattern
: new RegExp( '[' + mw
.config
.get( 'wgIllegalFileChars', '' ) + ']', 'g' ),
190 // brackets, greater than
196 // brackets, lower than
202 // everything that wasn't covered yet
204 pattern
: new RegExp( rInvalid
.source
, 'g' ),
208 // directory structures
210 pattern
: /^(\.|\.\.|\.\/.*|\.\.\/.*|.*\/\.\/.*|.*\/\.\.\/.*|.*\/\.|.*\/\.\.)$/g,
217 * Internal helper for #constructor and #newFromText.
219 * Based on Title.php#secureAndSplit
224 * @param {string} title
225 * @param {number} [defaultNamespace=NS_MAIN]
226 * @return {Object|boolean}
228 parse = function ( title
, defaultNamespace
) {
229 var namespace, m
, id
, i
, fragment
;
231 namespace = defaultNamespace
=== undefined ? NS_MAIN
: defaultNamespace
;
234 // Strip Unicode bidi override characters
235 .replace( rUnicodeBidi
, '' )
236 // Normalise whitespace to underscores and remove duplicates
237 .replace( rWhitespace
, '_' )
239 .replace( rUnderscoreTrim
, '' );
241 // Process initial colon
242 if ( title
!== '' && title
[ 0 ] === ':' ) {
243 // Initial colon means main namespace instead of specified default
249 .replace( rUnderscoreTrim
, '' );
252 if ( title
=== '' ) {
256 // Process namespace prefix (if any)
257 m
= title
.match( rSplit
);
259 id
= getNsIdByName( m
[ 1 ] );
260 if ( id
!== false ) {
261 // Ordinary namespace
265 // For Talk:X pages, make sure X has no "namespace" prefix
266 if ( namespace === NS_TALK
&& ( m
= title
.match( rSplit
) ) ) {
267 // Disallow titles like Talk:File:x (subject should roundtrip: talk:file:x -> file:x -> file_talk:x)
268 if ( getNsIdByName( m
[ 1 ] ) !== false ) {
276 i
= title
.indexOf( '#' );
281 // Get segment starting after the hash
284 // NB: Must not be trimmed ("Example#_foo" is not the same as "Example#foo")
285 .replace( /_
/g
, ' ' );
290 // Trim underscores, again (strips "_" from "bar" in "Foo_bar_#quux")
291 .replace( rUnderscoreTrim
, '' );
294 // Reject illegal characters
295 if ( rInvalid
.test( title
) ) {
299 // Disallow titles that browsers or servers might resolve as directory navigation
301 title
.indexOf( '.' ) !== -1 && (
302 title
=== '.' || title
=== '..' ||
303 title
.indexOf( './' ) === 0 ||
304 title
.indexOf( '../' ) === 0 ||
305 title
.indexOf( '/./' ) !== -1 ||
306 title
.indexOf( '/../' ) !== -1 ||
307 title
.slice( -2 ) === '/.' ||
308 title
.slice( -3 ) === '/..'
314 // Disallow magic tilde sequence
315 if ( title
.indexOf( '~~~' ) !== -1 ) {
319 // Disallow titles exceeding the TITLE_MAX_BYTES byte size limit (size of underlying database field)
320 // Except for special pages, e.g. [[Special:Block/Long name]]
321 // Note: The PHP implementation also asserts that even in NS_SPECIAL, the title should
322 // be less than 512 bytes.
323 if ( namespace !== NS_SPECIAL
&& mwString
.byteLength( title
) > TITLE_MAX_BYTES
) {
327 // Can't make a link to a namespace alone.
328 if ( title
=== '' && namespace !== NS_MAIN
) {
332 // Any remaining initial :s are illegal.
333 if ( title
[ 0 ] === ':' ) {
338 namespace: namespace,
345 * Convert db-key to readable text.
353 text = function ( s
) {
354 return s
.replace( /_
/g
, ' ' );
358 * Sanitizes a string based on a rule set and a filter
364 * @param {Array} filter
367 sanitize = function ( s
, filter
) {
368 var i
, ruleLength
, rule
, m
, filterLength
,
369 rules
= sanitationRules
;
371 for ( i
= 0, ruleLength
= rules
.length
; i
< ruleLength
; ++i
) {
373 for ( m
= 0, filterLength
= filter
.length
; m
< filterLength
; ++m
) {
374 if ( rule
[ filter
[ m
] ] ) {
375 s
= s
.replace( rule
.pattern
, rule
.replace
);
383 * Cuts a string to a specific byte length, assuming UTF-8
384 * or less, if the last character is a multi-byte one
388 * @method trimToByteLength
390 * @param {number} length
393 trimToByteLength = function ( s
, length
) {
394 return mwString
.trimByteLength( '', s
, length
).newVal
;
398 * Cuts a file name to a specific byte length
402 * @method trimFileNameToByteLength
403 * @param {string} name without extension
404 * @param {string} extension file extension
405 * @return {string} The full name, including extension
407 trimFileNameToByteLength = function ( name
, extension
) {
408 // There is a special byte limit for file names and ... remember the dot
409 return trimToByteLength( name
, FILENAME_MAX_BYTES
- extension
.length
- 1 ) + '.' + extension
;
413 * @method constructor
414 * @param {string} title Title of the page. If no second argument given,
415 * this will be searched for a namespace
416 * @param {number} [namespace=NS_MAIN] If given, will used as default namespace for the given title
417 * @throws {Error} When the title is invalid
419 function Title( title
, namespace ) {
420 var parsed
= parse( title
, namespace );
422 throw new Error( 'Unable to parse title' );
425 this.namespace = parsed
.namespace;
426 this.title
= parsed
.title
;
427 this.fragment
= parsed
.fragment
;
433 * Constructor for Title objects with a null return instead of an exception for invalid titles.
435 * Note that `namespace` is the **default** namespace only, and can be overridden by a namespace
436 * prefix in `title`. If you do not want this behavior, use #makeTitle. See #constructor for
440 * @param {string} title
441 * @param {number} [namespace=NS_MAIN] Default namespace
442 * @return {mw.Title|null} A valid Title object or null if the title is invalid
444 Title
.newFromText = function ( title
, namespace ) {
445 var t
, parsed
= parse( title
, namespace );
450 t
= Object
.create( Title
.prototype );
451 t
.namespace = parsed
.namespace;
452 t
.title
= parsed
.title
;
453 t
.fragment
= parsed
.fragment
;
459 * Constructor for Title objects with predefined namespace.
461 * Unlike #newFromText or #constructor, this function doesn't allow the given `namespace` to be
462 * overridden by a namespace prefix in `title`. See #constructor for details about this behavior.
464 * The single exception to this is when `namespace` is 0, indicating the main namespace. The
465 * function behaves like #newFromText in that case.
468 * @param {number} namespace Namespace to use for the title
469 * @param {string} title
470 * @return {mw.Title|null} A valid Title object or null if the title is invalid
472 Title
.makeTitle = function ( namespace, title
) {
473 return mw
.Title
.newFromText( getNamespacePrefix( namespace ) + title
);
477 * Constructor for Title objects from user input altering that input to
478 * produce a title that MediaWiki will accept as legal
481 * @param {string} title
482 * @param {number|Object} [defaultNamespaceOrOptions=NS_MAIN]
483 * If given, will used as default namespace for the given title.
484 * This method can also be called with two arguments, in which case
485 * this becomes options (see below).
486 * @param {Object} [options] additional options
487 * @param {boolean} [options.forUploading=true]
488 * Makes sure that a file is uploadable under the title returned.
489 * There are pages in the file namespace under which file upload is impossible.
490 * Automatically assumed if the title is created in the Media namespace.
491 * @return {mw.Title|null} A valid Title object or null if the input cannot be turned into a valid title
493 Title
.newFromUserInput = function ( title
, defaultNamespaceOrOptions
, options
) {
494 var namespace, m
, id
, ext
, lastDot
,
497 // defaultNamespace is optional; check whether options moves up
498 if ( arguments
.length
< 3 && typeof defaultNamespace
=== 'object' ) {
499 options
= defaultNamespaceOrOptions
;
501 defaultNamespace
= defaultNamespaceOrOptions
;
504 // merge options into defaults
505 options
= $.extend( {
509 namespace = defaultNamespace
=== undefined ? NS_MAIN
: defaultNamespace
;
511 // Normalise additional whitespace
512 title
= title
.replace( /\s/g, ' ' ).trim();
514 // Process initial colon
515 if ( title
!== '' && title
[ 0 ] === ':' ) {
516 // Initial colon means main namespace instead of specified default
522 .replace( rUnderscoreTrim
, '' );
525 // Process namespace prefix (if any)
526 m
= title
.match( rSplit
);
528 id
= getNsIdByName( m
[ 1 ] );
529 if ( id
!== false ) {
530 // Ordinary namespace
537 namespace === NS_MEDIA
||
538 ( options
.forUploading
&& ( namespace === NS_FILE
) )
540 title
= sanitize( title
, [ 'generalRule', 'fileRule' ] );
542 // Operate on the file extension
543 // Although it is possible having spaces between the name and the ".ext" this isn't nice for
544 // operating systems hiding file extensions -> strip them later on
545 lastDot
= title
.lastIndexOf( '.' );
547 // No or empty file extension
548 if ( lastDot
=== -1 || lastDot
>= title
.length
- 1 ) {
552 // Get the last part, which is supposed to be the file extension
553 ext
= title
.slice( lastDot
+ 1 );
555 // Remove whitespace of the name part (that without extension)
556 title
= title
.slice( 0, lastDot
).trim();
558 // Cut, if too long and append file extension
559 title
= trimFileNameToByteLength( title
, ext
);
561 title
= sanitize( title
, [ 'generalRule' ] );
563 // Cut titles exceeding the TITLE_MAX_BYTES byte size limit
564 // (size of underlying database field)
565 if ( namespace !== NS_SPECIAL
) {
566 title
= trimToByteLength( title
, TITLE_MAX_BYTES
);
570 // Any remaining initial :s are illegal.
571 title
= title
.replace( /^:+/, '' );
573 return Title
.newFromText( title
, namespace );
577 * Sanitizes a file name as supplied by the user, originating in the user's file system
578 * so it is most likely a valid MediaWiki title and file name after processing.
579 * Returns null on fatal errors.
582 * @param {string} uncleanName The unclean file name including file extension but
584 * @return {mw.Title|null} A valid Title object or null if the title is invalid
586 Title
.newFromFileName = function ( uncleanName
) {
587 return Title
.newFromUserInput( 'File:' + uncleanName
, {
593 * Get the file title from an image element
595 * var title = mw.Title.newFromImg( imageNode );
598 * @param {HTMLElement|jQuery} img The image to use as a base
599 * @return {mw.Title|null} The file title or null if unsuccessful
601 Title
.newFromImg = function ( img
) {
602 var matches
, i
, regex
, src
, decodedSrc
,
604 // thumb.php-generated thumbnails
605 thumbPhpRegex
= /thumb\.php/,
608 /\/[\da-f]\/[\da-f]{2}\/([^\s/]+)\/[^\s/]+-[^\s
/]*$/,
611 /\/[\da-f]\/[\da-f]{2}\/([^\s/]+)$/,
613 // Thumbnails in non-hashed upload directories
614 /\/([^\s/]+)\/[^\s/]+-(?:\1|thumbnail
)[^\s
/]*$/,
616 // Full-size images in non-hashed upload directories
620 recount
= regexes
.length
;
622 src
= img
.jquery
? img
[ 0 ].src
: img
.src
;
624 if ( thumbPhpRegex
.test( src
) ) {
625 return mw
.Title
.newFromText( 'File:' + mw
.util
.getParamValue( 'f', src
) );
628 decodedSrc
= decodeURIComponent( src
);
630 for ( i
= 0; i
< recount
; i
++ ) {
631 regex
= regexes
[ i
];
632 matches
= decodedSrc
.match( regex
);
634 if ( matches
&& matches
[ 1 ] ) {
635 return mw
.Title
.newFromText( 'File:' + matches
[ 1 ] );
643 * Check if a given namespace is a talk namespace
645 * See MWNamespace::isTalk in PHP
647 * @param {number} namespaceId Namespace ID
648 * @return {boolean} Namespace is a talk namespace
650 Title
.isTalkNamespace = function ( namespaceId
) {
651 return !!( namespaceId
> NS_MAIN
&& namespaceId
% 2 );
655 * Check if signature buttons should be shown in a given namespace
657 * See MWNamespace::wantSignatures in PHP
659 * @param {number} namespaceId Namespace ID
660 * @return {boolean} Namespace is a signature namespace
662 Title
.wantSignaturesNamespace = function ( namespaceId
) {
663 return Title
.isTalkNamespace( namespaceId
) ||
664 mw
.config
.get( 'wgExtraSignatureNamespaces' ).indexOf( namespaceId
) !== -1;
668 * Whether this title exists on the wiki.
671 * @param {string|mw.Title} title prefixed db-key name (string) or instance of Title
672 * @return {boolean|null} Boolean if the information is available, otherwise null
673 * @throws {Error} If title is not a string or mw.Title
675 Title
.exists = function ( title
) {
677 obj
= Title
.exist
.pages
;
679 if ( typeof title
=== 'string' ) {
680 match
= obj
[ title
];
681 } else if ( title
instanceof Title
) {
682 match
= obj
[ title
.toString() ];
684 throw new Error( 'mw.Title.exists: title must be a string or an instance of Title' );
687 if ( typeof match
!== 'boolean' ) {
695 * Store page existence
698 * @property {Object} exist
699 * @property {Object} exist.pages Keyed by title. Boolean true value indicates page does exist.
701 * @property {Function} exist.set The setter function.
703 * Example to declare existing titles:
705 * Title.exist.set( ['User:John_Doe', ...] );
707 * Example to declare titles nonexistent:
709 * Title.exist.set( ['File:Foo_bar.jpg', ...], false );
711 * @property {string|Array} exist.set.titles Title(s) in strict prefixedDb title form
712 * @property {boolean} [exist.set.state=true] State of the given titles
718 set: function ( titles
, state
) {
722 titles
= Array
.isArray( titles
) ? titles
: [ titles
];
723 state
= state
=== undefined ? true : !!state
;
725 for ( i
= 0, len
= titles
.length
; i
< len
; i
++ ) {
726 pages
[ titles
[ i
] ] = state
;
733 * Normalize a file extension to the common form, making it lowercase and checking some synonyms,
734 * and ensure it's clean. Extensions with non-alphanumeric characters will be discarded.
735 * Keep in sync with File::normalizeExtension() in PHP.
737 * @param {string} extension File extension (without the leading dot)
738 * @return {string} File extension in canonical form
740 Title
.normalizeExtension = function ( extension
) {
742 lower
= extension
.toLowerCase(),
750 if ( Object
.hasOwnProperty
.call( normalizations
, lower
) ) {
751 return normalizations
[ lower
];
752 } else if ( /^[\da-z]+$/.test( lower
) ) {
760 * PHP's strtoupper differs from String.toUpperCase in a number of cases (T147646).
762 * @param {string} chr Unicode character
763 * @return {string} Unicode character, in upper case, according to the same rules as in PHP
765 Title
.phpCharToUpper = function ( chr
) {
767 toUpperMap
= require( './phpCharToUpper.json' );
769 if ( toUpperMap
[ chr
] === '' ) {
770 // Optimisation: When the override is to keep the character unchanged,
771 // we use an empty string in JSON. This reduces the data by 50%.
774 return toUpperMap
[ chr
] || chr
.toUpperCase();
783 * Get the namespace number
785 * Example: 6 for "File:Example_image.svg".
789 getNamespaceId: function () {
790 return this.namespace;
794 * Get the namespace prefix (in the content language)
796 * Example: "File:" for "File:Example_image.svg".
797 * In #NS_MAIN this is '', otherwise namespace name plus ':'
801 getNamespacePrefix: function () {
802 return getNamespacePrefix( this.namespace );
806 * Get the page name without extension or namespace prefix
808 * Example: "Example_image" for "File:Example_image.svg".
810 * For the page title (full page name without namespace prefix), see #getMain.
814 getName: function () {
815 var ext
= this.getExtension();
816 if ( ext
=== null ) {
817 return this.getMain();
819 return this.getMain().slice( 0, -ext
.length
- 1 );
823 * Get the page name (transformed by #text)
825 * Example: "Example image" for "File:Example_image.svg".
827 * For the page title (full page name without namespace prefix), see #getMainText.
831 getNameText: function () {
832 return text( this.getName() );
836 * Get the extension of the page name (if any)
838 * @return {string|null} Name extension or null if there is none
840 getExtension: function () {
841 var lastDot
= this.title
.lastIndexOf( '.' );
842 if ( lastDot
=== -1 ) {
845 return this.title
.slice( lastDot
+ 1 ) || null;
849 * Shortcut for appendable string to form the main page name.
851 * Returns a string like ".json", or "" if no extension.
855 getDotExtension: function () {
856 var ext
= this.getExtension();
857 return ext
=== null ? '' : '.' + ext
;
861 * Get the main page name
863 * Example: "Example_image.svg" for "File:Example_image.svg".
867 getMain: function () {
869 mw
.config
.get( 'wgCaseSensitiveNamespaces' ).indexOf( this.namespace ) !== -1 ||
874 return mw
.Title
.phpCharToUpper( this.title
[ 0 ] ) + this.title
.slice( 1 );
878 * Get the main page name (transformed by #text)
880 * Example: "Example image.svg" for "File:Example_image.svg".
884 getMainText: function () {
885 return text( this.getMain() );
889 * Get the full page name
891 * Example: "File:Example_image.svg".
892 * Most useful for API calls, anything that must identify the "title".
896 getPrefixedDb: function () {
897 return this.getNamespacePrefix() + this.getMain();
901 * Get the full page name (transformed by #text)
903 * Example: "File:Example image.svg" for "File:Example_image.svg".
907 getPrefixedText: function () {
908 return text( this.getPrefixedDb() );
912 * Get the page name relative to a namespace
916 * - "Foo:Bar" relative to the Foo namespace becomes "Bar".
917 * - "Bar" relative to any non-main namespace becomes ":Bar".
918 * - "Foo:Bar" relative to any namespace other than Foo stays "Foo:Bar".
920 * @param {number} namespace The namespace to be relative to
923 getRelativeText: function ( namespace ) {
924 if ( this.getNamespaceId() === namespace ) {
925 return this.getMainText();
926 } else if ( this.getNamespaceId() === NS_MAIN
) {
927 return ':' + this.getPrefixedText();
929 return this.getPrefixedText();
934 * Get the fragment (if any).
936 * Note that this method (by design) does not include the hash character and
937 * the value is not url encoded.
939 * @return {string|null}
941 getFragment: function () {
942 return this.fragment
;
946 * Get the URL to this title
948 * @see mw.util#getUrl
949 * @param {Object} [params] A mapping of query parameter names to values,
950 * e.g. `{ action: 'edit' }`.
953 getUrl: function ( params
) {
954 var fragment
= this.getFragment();
956 return mw
.util
.getUrl( this.toString() + '#' + fragment
, params
);
958 return mw
.util
.getUrl( this.toString(), params
);
963 * Check if the title is in a talk namespace
965 * @return {boolean} The title is in a talk namespace
967 isTalkPage: function () {
968 return Title
.isTalkNamespace( this.getNamespaceId() );
972 * Get the title for the associated talk page
974 * @return {mw.Title|null} The title for the associated talk page, null if not available
976 getTalkPage: function () {
977 if ( !this.canHaveTalkPage() ) {
980 return this.isTalkPage() ?
982 Title
.makeTitle( this.getNamespaceId() + 1, this.getMainText() );
986 * Get the title for the subject page of a talk page
988 * @return {mw.Title|null} The title for the subject page of a talk page, null if not available
990 getSubjectPage: function () {
991 return this.isTalkPage() ?
992 Title
.makeTitle( this.getNamespaceId() - 1, this.getMainText() ) :
997 * Check the the title can have an associated talk page
999 * @return {boolean} The title can have an associated talk page
1001 canHaveTalkPage: function () {
1002 return this.getNamespaceId() >= NS_MAIN
;
1006 * Whether this title exists on the wiki.
1008 * @see #static-method-exists
1009 * @return {boolean|null} Boolean if the information is available, otherwise null
1011 exists: function () {
1012 return Title
.exists( this );
1017 * @alias #getPrefixedDb
1020 Title
.prototype.toString
= Title
.prototype.getPrefixedDb
;
1023 * @alias #getPrefixedText
1026 Title
.prototype.toText
= Title
.prototype.getPrefixedText
;