trimFileNameToByteLength = function ( name, extension ) {
// There is a special byte limit for file names and ... remember the dot
return trimToByteLength( name, FILENAME_MAX_BYTES - extension.length - 1 ) + '.' + extension;
- },
-
- // Polyfill for ES5 Object.create
- createObject = Object.create || ( function () {
- return function ( o ) {
- function Title() {}
- if ( o !== Object( o ) ) {
- throw new Error( 'Cannot inherit from a non-object' );
- }
- Title.prototype = o;
- return new Title();
- };
- }() );
+ };
/* Static members */
return null;
}
- t = createObject( Title.prototype );
+ t = Object.create( Title.prototype );
t.namespace = parsed.namespace;
t.title = parsed.title;
t.ext = parsed.ext;
namespace = defaultNamespace === undefined ? NS_MAIN : defaultNamespace;
// Normalise additional whitespace
- title = $.trim( title.replace( /\s/g, ' ' ) );
+ title = title.replace( /\s/g, ' ' ).trim();
// Process initial colon
if ( title !== '' && title[ 0 ] === ':' ) {
ext = parts.pop();
// Remove whitespace of the name part (that W/O extension)
- title = $.trim( parts.join( '.' ) );
+ title = parts.join( '.' ).trim();
// Cut, if too long and append file extension
title = trimFileNameToByteLength( title, ext );
} else {
// Missing file extension
- title = $.trim( parts.join( '.' ) );
+ title = parts.join( '.' ).trim();
// Name has no file extension and a fallback wasn't provided either
return null;