How to use the path.win32 function in path

To help you get started, we’ve selected a few 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 daviddbarrero / Ionic-4-firebase / node_modules / loader-utils / lib / isUrlRequest.js View on Github external
function isUrlRequest(url, root) {
  // An URL is not an request if

  // 1. It's an absolute url and it is not `windows` path like `C:\dir\file`
  if (/^[a-z][a-z0-9+.-]*:/i.test(url) && !path.win32.isAbsolute(url)) {
    return false;
  }

  // 2. It's a protocol-relative
  if (/^\/\//.test(url)) {
    return false;
  }

  // 3. It's some kind of url for a template
  if (/^[{}[\]#*;,'§$%&(=?`´^°<>]/.test(url)) {
    return false;
  }

  // 4. It's also not an request if root isn't set and it's a root-relative url
  if ((root === undefined || root === false) && /^\//.test(url)) {
    return false;
github npm / tink / lib / ensure-package.js View on Github external
const parts = entry.path.split(/\/|\\/)
      if (parts.length < this.strip) {
        return false
      }
      entry.path = parts.slice(this.strip).join('/')
    }

    const p = entry.path
    if (p.match(/(^|\/|\\)\.\.(\\|\/|$)/)) {
      this.warn('path contains \'..\'', p)
      return false
    }

    // absolutes on posix are also absolutes on win32
    // so we only need to test this one to get both
    if (path.win32.isAbsolute(p)) {
      const parsed = path.win32.parse(p)
      this.warn('stripping ' + parsed.root + ' from absolute path', p)
      entry.path = p.substr(parsed.root.length)
    }

    if (path.isAbsolute(entry.path)) {
      this.warn('absolute paths are not allowed', entry.path)
    }

    return true
  }
github darekf77 / morphi / src / build-tool / helpers.ts View on Github external
export function createLink(target: string, link: string) {
    if (isPlainFileOrFolder(link)) {
      link = path.join(process.cwd(), link);
    }

    let command: string;
    if (os.platform() === 'win32') {

      if (target.startsWith('./')) {
        target = path.win32.normalize(path.join(process.cwd(), path.basename(target)))
      } else {
        if (target === '.' || target === './') {
          target = path.win32.normalize(path.join(process.cwd(), path.basename(link)))
        } else {
          target = path.win32.normalize(path.join(target, path.basename(link)))
        }
      }
      if (fs.existsSync(target)) {
        fs.unlinkSync(target);
      }
      target = path.win32.normalize(target)
      if (link === '.' || link === './') {
        link = process.cwd()
      }
      link = path.win32.normalize(link)
      // console.log('taget', target)
github johandb / svg-drawing-tool / node_modules / webpack / lib / util / identifier.js View on Github external
.map(r => {
			const splitPath = r.split("?", 2);
			if (/^[a-zA-Z]:\\/.test(splitPath[0])) {
				splitPath[0] = path.win32.relative(context, splitPath[0]);
				if (!/^[a-zA-Z]:\\/.test(splitPath[0])) {
					splitPath[0] = splitPath[0].replace(/\\/g, "/");
				}
			}
			if (/^\//.test(splitPath[0])) {
				splitPath[0] = path.posix.relative(context, splitPath[0]);
			}
			if (!/^(\.\.\/|\/|[a-zA-Z]:\\)/.test(splitPath[0])) {
				splitPath[0] = "./" + splitPath[0];
			}
			return splitPath.join("?");
		})
		.join("!");
github joshuaskelly / vscode-quakec / server / src / language.ts View on Github external
private validateProgramCache(stopAtUri?: string) {
        console.log("Validating AST Cache...");
        let start: number = new Date().getTime();
        this.documentsParsed = 0;
        let done: boolean = false;

        if (this.sourceOrder) {
            let scope: Scope = null;

            for (let i = 0; i < this.sourceOrder.length; i++) {
                let uri: string = this.sourceOrder[i];

                console.log(`   Validating ${path.win32.basename(uri)}`);
                var program: Program = this.validateProgram(uri, scope);

                if (program) {
                    scope = program.scope;
                }

                if (uri === stopAtUri) {
                    done = true;
                    break;
                }
            }
        }

        if (!done) {
            for (let uri in this.programs) {
                this.validateProgram(uri);
github joshuaskelly / vscode-quakec / server / src / language.ts View on Github external
private isProjectDocument(uri: string) {
        return path.win32.basename(uri) === "progs.src";
    }
github eBay / arc / packages / arc-resolver / index.js View on Github external
function getPathHelper(filepath) {
  if (path.posix.isAbsolute(filepath)) {
    return path.posix;
  } else if (path.win32.isAbsolute(filepath)) {
    return path.win32;
  } else {
    throw new Error(
      'Filepath must be a fully resolved filepath. Got: ' + filepath
    );
  }
}
github tensorflow / tfjs-node / tfjs-node / scripts / resources.js View on Github external
*
 * 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.
 * =============================================================================
 */

const fs = require('fs');
const https = require('https');
const HttpsProxyAgent = require('https-proxy-agent');
const path = require('os').platform() === 'win32' ? require('path') :
                                                    require('path').win32;
const ProgressBar = require('progress');
const tar = require('tar');
const url = require('url');
const util = require('util');
const zip = require('adm-zip');

const unlink = util.promisify(fs.unlink);

/**
 * Downloads and unpacks a given tarball or zip file at a given path.
 * @param {string} uri The path of the compressed file to download and extract.
 * @param {string} destPath The destination path for the compressed content.
 * @param {Function} callback Handler for when downloading and extraction is
 *     complete.
 */
async function downloadAndUnpackResource(uri, destPath, callback) {