INNER CODE UNIT · JavaScript

hasScheme

geekjourneyx/md2wechat-skill · scripts/install.js:52

function hasScheme(value) {
  return (
    /^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(value) && !path.win32.isAbsolute(value)
  );
}

function resolveAssetLocation(base, name) {
  if (!hasScheme(base)) {
    return path.join(base, name);
  }

  return base.endsWith("/") ? `${base}${name}` : `${base}/${name}`;
}

function downloadToFile(source, destinationPath) {
  if (!hasScheme(source)) {
    fs.copyFileSync(source, destinationPath);
    return Promise.resolve();

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…