Skip to content

Commit

Permalink
test/test_helpers.js: use path.extname to get the extension
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR committed Oct 1, 2019
1 parent a747ea3 commit aebbbca
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions test/test_helpers.js
Expand Up @@ -6,6 +6,7 @@ const ENV = process.env;
ENV.BCDN_HEADERS = ENV.BCDN_HEADERS || 'production';

const assert = require('assert').strict;
const path = require('path');
const { htmlEncode } = require('htmlencode');
const mockDate = require('mockdate');
const request = require('request');
Expand All @@ -22,14 +23,7 @@ let server = {};
mockDate.set('03/05/2018');

function getExtension(str) {
// use two enclosing parts; one for the dot (.)
// and one for the extension itself.
// So, the result we want is the third Array element,
// since the first one is the whole match, the second one
// returns the first captured match, etc.
const match = str.match(/(\.)([a-zA-Z0-9]+)$/);

return match && match[2];
return path.extname(str).slice(1);
}

// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
Expand Down

0 comments on commit aebbbca

Please sign in to comment.