INNER CODE UNIT · JavaScript

stripPrefix

chadbyte/clay · lib/server.js:128

function stripPrefix(urlPath, slug) {
  var prefix = "/p/" + slug;
  var rest = urlPath.substring(prefix.length);
  return rest || "/";
}

function injectRootProjectSlug(html, slug) {
  var bodyPattern = /<body\b([^>]*)>/i;
  if (!bodyPattern.test(html)) throw new Error("App shell body is missing");
  return html.replace(bodyPattern, function (_match, attributes) {
    return '<body' + attributes + ' data-home-project-slug="' + slug + '">';
  });
}

/**
 * Create a multi-project server.
 * opts: { tlsOptions, caPath, pinHash, port, debug, dangerouslySkipPermissions }
 */

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…