How to use the binary-extensions.map function in binary-extensions

To help you get started, we’ve selected a few binary-extensions examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github 1000ch / rog / index.js View on Github external
'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);
  }

binary-extensions

List of binary file extensions

MIT
Latest version published 6 months ago

Package Health Score

82 / 100
Full package analysis