Code coverage report for Livewire/lib/compiler.js

Statements: 100% (32 / 32)      Branches: 87.5% (7 / 8)      Functions: 100% (7 / 7)      Lines: 100% (32 / 32)      Ignored: none     

All files » Livewire/lib/ » compiler.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 471 1 1 1 1 5   1 9 9 9 9 9 1 1   9 9   4   3   2     9 8 8 8 7 7 7 7 1 1 1   7     1          
(function(){
  var ref$, Some, None, parseUrl, last, compilePath, out$ = typeof exports != 'undefined' && exports || this, slice$ = [].slice;
  ref$ = require('fantasy-options'), Some = ref$.Some, None = ref$.None;
  parseUrl = require('url').parse;
  last = function(it){
    return it[it.length - 1];
  };
  out$.compilePath = compilePath = function(path){
    var ident, sigil, params, paramReg, reg;
    ident = '[a-z$_][a-z0-9$_]*';
    sigil = ':';
    params = [];
    paramReg = path.replace(RegExp(sigil + '(' + ident + ')', 'i'), function(m, param){
      params.push(param);
      return '([^\\/]+)';
    });
    reg = (function(){
      switch (false) {
      case path !== '/':
        return /^\/$/;
      case '/' !== last(path):
        return RegExp('^' + paramReg + '?', 'i');
      default:
        return RegExp('^' + paramReg + '\\/?$', 'i');
      }
    }());
    return function(url){
      var pathname, that, route, vals, i, val;
      pathname = parseUrl(url).pathname;
      if ((that = reg.exec(pathname)) != null) {
        route = that[0], vals = slice$.call(that, 1);
        return Some((function(){
          var i$, ref$, len$, results$ = {};
          for (i$ = 0, len$ = (ref$ = vals).length; i$ < len$; ++i$) {
            i = i$;
            val = ref$[i$];
            results$[params[i]] = val;
          }
          return results$;
        }()));
      } else {
        return None;
      }
    };
  };
}).call(this);