Package Exports
- regex-extname
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (regex-extname) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Filename Extension
Regular expression to capture a filename extension.
Installation
$ npm install regex-extname
Usage
var re = require( 'regex-extname' );
re
Regular expression to capture a filename extension.
var ext;
// On a POSIX platform...
ext = re.exec( '/foo/bar/index.js' )[ 1 ];
// returns '.js'
// On a Windows platform...
ext = re.exec( 'C:\\foo\\bar\\index.js' )[ 1 ];
// returns '.js'
re.posix
Regular expression to capture a POSIX filename extension.
re.win32
Regular expression to capture a Windows filename extension.
Notes
The main exported [regular expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions) is [platform](https://github.com/kgryte/node-check-if-windows)-dependent. If the current process is running on Windows, `re === re.win32`; otherwise, `re === re.posix`.
Examples
var re = require( 'regex-extname' );
var ext;
// Assuming a POSIX platform...
ext = re.exec( '/foo/bar/index.js' )[ 1 ];
console.log( ext );
// returns '.js'
ext = re.posix.exec( '/foo/bar/home.html' )[ 1 ];
console.log( ext );
// returns '.html'
ext = re.win32.exec( 'C:\\foo\\bar\\home.html' )[ 1 ];
console.log( ext );
// returns '.html'
To run the example code from the top-level application directory,
$ node ./examples/index.js
Tests
Unit
Unit tests use the Mocha test framework with Chai assertions. To run the tests, execute the following command in the top-level application directory:
$ make test
All new feature development should have corresponding unit tests to validate correct functionality.
Test Coverage
This repository uses Istanbul as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory:
$ make test-cov
Istanbul creates a ./reports/coverage
directory. To access an HTML version of the report,
$ make view-cov
License
Copyright
Copyright © 2015. Athan Reines.