Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function isFileNameBinary (filepath) {
const ext = path.extname(filepath)
if (binextensions.includes(ext)) return true
if (textextensions.includes(ext)) return false
// dont know
}
exports.isFileNameBinary = function (filepath) {
const ext = path.extname(filepath)
if (binextensions.includes(ext)) return true
if (textextensions.includes(ext)) return false
// dont know
}
function isTextFile (filePath) {
return !binaries.includes(filePath.split('.').pop());
}
function isBinaryExtension (fileName) {
var nameParts = fileName.split('.')
if (nameParts.length > 1) {
var ext = nameParts.pop()
if (ext && BINARY_EXTENSIONS.includes(ext.toLowerCase()) === true) {
return true
}
}
return false
}
function isBinaryExtension (fileName) {
var nameParts = fileName.split('.')
if (nameParts.length > 1) {
lastTriedExt = nameParts.pop()
if (lastTriedExt && BINARY_EXTENSIONS.includes(lastTriedExt.toLowerCase()) === true) {
return true
}
}
return false
}
isBinary(filepath) {
const ext = path.extname(filepath).slice(1).toLowerCase();
return (this.options.binary_resource || '').toLowerCase().split(',').indexOf(ext) > -1 || binaryExtensions.indexOf(ext) > -1;
}
locate(name) {
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';
var path = require('path');
var binaryExtensions = require('binary-extensions');
var exts = Object.create(null);
binaryExtensions.forEach(function (el) {
exts[el] = true;
});
module.exports = function (filepath) {
return path.extname(filepath).slice(1).toLowerCase() in exts;
};
'use strict';
const got = require('got');
const isURL = require('is-url');
const binaryExtensions = require('binary-extensions');
const isHTML = require('is-html');
const cheerio = require('cheerio');
const jschardet = require('jschardet');
const iconv = require('iconv-lite');
const binaries = new RegExp(`(${binaryExtensions.map(ext => `.${ext}`).join('|')})$`);
const getBody = response => {
const headers = response.headers || {};
const body = response.body || '';
const contentType = headers['content-type'] || '';
const matches = contentType.match(/charset=(?.+)/);
if (matches !== null) {
return iconv.decode(body, matches[1]);
}
const result = jschardet.detect(body);
if (result && result.encoding && (result.confidence || 0) >= 0.99) {
return iconv.decode(body, result.encoding);
}