title: Converting an absolute path to a relative path
body: <p>Working in Node I need to convert my request path into a relative path so I can drop it into some templates that have a different folder structure.</p>
  <p>For example, if I start with the path &quot;/foo/bar&quot; and want the relative path to &quot;/foo&quot;, it would be &quot;..&quot;, and for &quot;/foo/bar/baz&quot; it would be &quot;../..&quot;.</p>
  <p>I wrote a pair of functions to do this:</p>
  <pre><code>function splitPath(path) {
      return path.split('/').map(dots).slice(2).join('/');
  }
  
  function dots() {
      return '..';
  }
  </code></pre>
  <p>Not sure if this is the best approach or if it's possible to do it with a regular expression in String.replace somehow?</p>
  <p><strong>edit</strong></p>
  <p>I should point out this is so I can render everything as static HTML, zip up the whole project, and send it to someone who doesn't have access to a web server. See my first comment.</p>