How to use sanitize-filename - 10 common examples

To help you get started, we’ve selected a few sanitize-filename 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 emfmesquita / beyondhelp / src / optionspage / extramaprefs / ExtraMapRefsOptions.js View on Github external
handleExport = (bundle: ExtraMapRefsData) => {
        chrome.downloads.download({
            url: `data:text/plain,${toJson(bundle.content)}`,
            filename: `${sanitize(bundle.content.name.substr(0, 40))}.json`
        });

        // closes the confirm modal
        this.setState({ toExportWithErrorsBundle: null });
    }
github DevExpress / testcafe / test / functional / fixtures / api / es-next / take-screenshot / testcafe-fixtures / take-screenshot.js View on Github external
test('Take screenshots for reporter', async t => {
    const ua            = await getUserAgent();
    const safeUserAgent = sanitizeFilename(parseUserAgent(ua).prettyUserAgent).replace(/\s+/g, '_');

    quarantineScope[safeUserAgent] = quarantineScope[safeUserAgent] || {};

    const attemptNumber = quarantineScope[safeUserAgent].attemptNumber || 1;

    const getFileName = fileName => {
        return safeUserAgent + attemptNumber + fileName;
    };

    await t
        .takeScreenshot(getFileName('1.png'))
        .takeElementScreenshot('body', getFileName('2.png'));

    quarantineScope[safeUserAgent].attemptNumber = attemptNumber + 1;

    if (attemptNumber === 1)
github odota / web / testcafe / testsUtility.js View on Github external
function path2file(url) {
  return sanitize(url.replace('https://api.opendota.com/api/', ''), {
    replacement: '_',
  }).substr(0, 200);
}
github AJInteractive / InterviewJS / packages / composer / src / partials / panes / user / tabs / Image.js View on Github external
handleBlob(blob, type, name) {
    const key = fileToKey(
      { type, name: sanitizeFilename(name.replace(/ /g, "_")) },
      this.props.story.id
    );
    Storage.put(
      `files/${this.props.user.id}/${this.props.story.id}/${key}`,
      blob,
      {
        bucket: "data.interviewjs.io",
        level: "public",
        contentType: type
      }
    )
      .then(async (result) => {
        console.log(result);
        this.setState(
          {
            draft: {
github OpusCapita / filemanager / packages / connector-node-v1 / src / capabilities / rename.js View on Github external
onValidate: async (name) => {
        if (!name) {
          return getMessage('emptyName');
        } else if (name.length >= 255) {
          return getMessage('tooLongFolderName');
        } else if (name.trim() !== sanitizeFilename(name.trim())) {
          return getMessage('folderNameNotAllowedCharacters');
        }
        return null;
      },
      inputLabelText: getMessage('newName'),
github hasura / graphql-engine / console / src / components / Services / Data / DataActions.js View on Github external
successMsg,
  errorMsg,
  shouldSkipSchemaReload
) => {
  const upQuery = {
    type: 'bulk',
    args: upQueries,
  };

  const downQuery = {
    type: 'bulk',
    args: downQueries,
  };

  const migrationBody = {
    name: sanitize(migrationName),
    up: upQuery.args,
    down: downQuery.args,
  };

  const currMigrationMode = getState().main.migrationMode;

  const migrateUrl = returnMigrateUrl(currMigrationMode);

  let finalReqBody;
  if (globals.consoleMode === SERVER_CONSOLE_MODE) {
    finalReqBody = upQuery;
  } else if (globals.consoleMode === CLI_CONSOLE_MODE) {
    finalReqBody = migrationBody;
  }
  const url = migrateUrl;
  const options = {
github alphasp / pxview / src / components / HOC / enhanceSaveImage.js View on Github external
index,
    ) => {
      let fileName;
      switch (saveImageSettings.fileName) {
        case SAVE_FILE_NAME_FORMAT.WORK_TITLE:
          fileName = `${workTitle}_p${index}.jpg`;
          break;
        case SAVE_FILE_NAME_FORMAT.WORK_ID_WORK_TITLE:
          fileName = `${workId}_${workTitle}_p${index}.jpg`;
          break;
        case SAVE_FILE_NAME_FORMAT.WORK_ID:
        default:
          fileName = `${workId}_p${index}.jpg`;
          break;
      }
      return sanitize(fileName, {
        replacement: '_',
      });
    };
github Soluto / dynamico / server / express-middleware / lib / controller.ts View on Github external
export const get = (driver: Driver) => async (req: Request, res: Response) => {
  if (req.query.componentVersion && !valid(req.query.componentVersion)) {
    throw new InvalidVersionError({ componentVersion: req.query.componentVersion });
  }

  const name = sanitizeFilename(req.params.name);
  const { hostId, componentVersion } = req.query;

  const { version, getCode } = await driver.getComponent({
    hostId,
    name,
    version: componentVersion
  });

  res.setHeader('Dynamico-Component-Version', version);

  return getCode();
};
github electron-userland / electron-builder / packages / app-builder-lib / src / appInfo.ts View on Github external
if (buildVersion == null) {
      buildVersion = info.config.buildVersion
    }

    this.buildNumber = process.env.BUILD_NUMBER || process.env.TRAVIS_BUILD_NUMBER || process.env.APPVEYOR_BUILD_NUMBER || process.env.CIRCLE_BUILD_NUM || process.env.BUILD_BUILDNUMBER || process.env.CI_PIPELINE_IID
    if (buildVersion == null) {
      buildVersion = this.version
      if (!isEmptyOrSpaces(this.buildNumber)) {
        buildVersion += `.${this.buildNumber}`
      }
    }
    this.buildVersion = buildVersion

    this.productName = info.config.productName || info.metadata.productName || info.metadata.name!!
    this.productFilename = sanitizeFileName(this.productName)
  }
github egm0121 / splitcloud-app / modules / MediaLibraryApi.js View on Github external
getArtworkFilenameForTrack(track){
    return sanitizeFilename(track.label + '-' + track.username + '.jpg').replace(' ','_');
  }
  getArtworkForTrack(track){

sanitize-filename

Sanitize a string for use as a filename

WTFPL OR ISC
Latest version published 5 years ago

Package Health Score

67 / 100
Full package analysis

Popular sanitize-filename functions