21 lines
440 B
JavaScript
21 lines
440 B
JavaScript
'use strict';
|
|
|
|
const oneLineRegex = /^\/\/(.*?)\n?$/;
|
|
const multiLineRegex = /^\/\*([\s\S]*?)\*\/$/;
|
|
|
|
exports.isComment = function( input ) {
|
|
if ( oneLineRegex.test( input ) || multiLineRegex.test( input ) ) {
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
};
|
|
|
|
exports.getCommentContent = function( input ) {
|
|
if ( oneLineRegex.test( input ) ) {
|
|
return input.replace( /^\/\//, '' );
|
|
}
|
|
|
|
return input.replace( /^\/\*/, '' ).replace( /\*\/$/, '' );
|
|
}
|