title: Javascript method for changing snake_case to PascalCase
body: <p>I'm looking for a JS method that will turn <code>snake_case</code> into <code>PascalCase</code> while keeping slashes intact.</p>
  
  <pre><code>// examples:
  post -&gt; Post
  admin_post -&gt; AdminPost
  admin_post/new -&gt; AdminPost/New
  admin_post/delete_post -&gt; AdminPost/DeletePost
  </code></pre>
  
  <p>etc.</p>
  
  <p>I have something that will turn <code>snake_case</code> into <code>camelCase</code> and preserve slashes, but I'm having trouble converting this for <code>PascalCase</code></p>
  
  <p>Here's what I've got so far:</p>
  
  <pre><code>_snakeToPascal(string){
      return string.replace(/(_\w)/g, (m) =&gt; {
        return m[1].toUpperCase();
      });
    }
  </code></pre>
  
  <p>Any advice is appreciated!</p>
  
  <h1>EDIT - Solution found</h1>
  
  <p>Here is what I ended up using.  If you use this be mindful that I'm using <code>this._upperFirst</code> since I'm using it in a class.  It's kinda greasy but it works.</p>
  
  <pre><code>  _snakeToPascal(string){
      return string.split('_').map((str) =&gt; {
        return this._upperFirst(
          str.split('/')
          .map(this._upperFirst)
          .join('/'));
      }).join('');
    }
  
    _upperFirst(string) {
      return string.slice(0, 1).toUpperCase() + string.slice(1, string.length);
    }
  </code></pre>