How to use is-invalid-path - 2 common examples

To help you get started, we’ve selected a few is-invalid-path 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 mutaimwiti / node-test-wrapper / src / utils / file.js View on Github external
const fileAvailable = (filePath) => {
  if (
    isInvalidPath(filePath) ||
    filePath.endsWith('/') ||
    filePath.endsWith('\\')
  ) {
    return `'${filePath}' is not a valid file path`;
  }

  if (filePath.startsWith('/') || filePath.startsWith('\\')) {
    return 'Specify a relative file path';
  }

  const jsPath = jsExtensionPath(filePath);

  if (fs.existsSync(jsPath)) {
    const stats = fs.statSync(jsPath);
    return stats.isDirectory()
      ? `'${jsPath}' is a directory`
github VirgilSecurity / virgil-e3kit-js / packages / e3kit-node / src / EThree.ts View on Github external
});
        const keyLoader = new PrivateKeyLoader(identity, {
            accessTokenProvider,
            virgilCrypto,
            brainKeyCrypto,
            keyEntryStorage,
            apiUrl: opts.apiUrl,
        });
        const cardManager = new CardManager({
            cardCrypto,
            cardVerifier,
            accessTokenProvider,
            retryOnUnauthorized: true,
            apiUrl: opts.apiUrl,
        });
        if (isInvalidPath(opts.groupStorageName!)) {
            throw new TypeError('`groupStorageName` is not a valid path');
        }
        mkdirp.sync(opts.groupStorageName!);
        const groupStorageLeveldown = leveldown(opts.groupStorageName!);

        super({
            identity,
            virgilCrypto,
            cardManager,
            accessTokenProvider,
            keyEntryStorage,
            keyLoader,
            groupStorageLeveldown,
        });
    }

is-invalid-path

Returns true if a windows file path has invalid characters.

MIT
Latest version published 6 years ago

Package Health Score

68 / 100
Full package analysis

Popular is-invalid-path functions