'use strict';

/**
* Regular expression to capture a filename extension.
*
* @module @stdlib/regexp/extname
* @type {RegExp}
*
* @example
* var RE_EXTNAME = require( '@stdlib/regexp/extname' );
*
* // On a POSIX platform...
* var ext = RE_EXTNAME.exec( '/foo/bar/index.js' )[ 1 ];
* // returns '.js'
*
* @example
* var RE_EXTNAME = require( '@stlib/regexp/extname' );
*
* // On a Windows platform...
* var ext = RE_EXTNAME.exec( 'C:\\foo\\bar\\index.js' )[ 1 ];
* // returns '.js'
*/

// MODULES //

var copy = require( '@stdlib/utils/copy' );
var isWindows = require( '@stdlib/utils/is-windows' );


// MAIN //

var posix = require( '@stdlib/regexp/extname-posix' );
var win32 = require( '@stdlib/regexp/extname-windows' );

var re;
if ( isWindows ) {
	re = win32;
} else {
	re = posix;
}
re = copy( re );


// EXPORTS //

module.exports = re;
module.exports.posix = posix;
module.exports.win32 = win32;

'use strict';

/**
* Regular expression to capture a filename extension.
*
* @module @stdlib/regexp/extname
* @type {RegExp}
*
* @example
* var RE_EXTNAME = require( '@stdlib/regexp/extname' );
*
* // On a POSIX platform...
* var ext = RE_EXTNAME.exec( '/foo/bar/index.js' )[ 1 ];
* // returns '.js'
*
* @example
* var RE_EXTNAME = require( '@stlib/regexp/extname' );
*
* // On a Windows platform...
* var ext = RE_EXTNAME.exec( 'C:\\foo\\bar\\index.js' )[ 1 ];
* // returns '.js'
*/

// MODULES //

var setReadOnly = require( '@stdlib/utils/define-read-only-property' );
var copy = require( '@stdlib/utils/copy' );
var IS_WINDOWS = require( '@stdlib/utils/is-windows' );


// MAIN //

var posix = require( '@stdlib/regexp/extname-posix' );
var win32 = require( '@stdlib/regexp/extname-windows' );

var RE_EXTNAME;
if ( IS_WINDOWS ) {
	RE_EXTNAME = win32;
} else {
	RE_EXTNAME = posix;
}
RE_EXTNAME = copy( RE_EXTNAME );

setReadOnly( RE_EXTNAME, 'posix', posix );
setReadOnly( RE_EXTNAME, 'win32', win32 );


// EXPORTS //

module.exports = RE_EXTNAME;

Set read only properties