function parseRoute(url) {
    var ret = {
      regexp: url
    },
    keys = ret.keys = [];

    if (!url || !angular.isString(url)) return ret;

    url = url
      .replace(/([().])/g, '\\$1')
      .replace(/(\/)?:(\w+)([\?\*])?/g, function(_, slash, key, option) {
        var optional = option === '?' ? option : null;
        var star = option === '*' ? option : null;
        keys.push({ name: key, optional: !!optional });
        slash = slash || '';
        return ''
          + (optional ? '' : slash)
          + '(?:'
          + (optional ? slash : '')
          + (star && '(.+?)' || '([^/]+)')
          + (optional || '')
          + ')'
          + (optional || '');
      })
      .replace(/([\/$\*])/g, '\\$1');

    ret.regexp = new RegExp('^' + url, 'i');
    return ret;
  }
@ngdoc method
@name $httpBackend#whenRoute
@description
Creates a new backend definition that compares only with the requested route.

@param {string} method HTTP method.
@param {string} url HTTP url string that supports colon param matching.
@returns {requestHandler} Returns an object with `respond` method that controls how a matched
request is handled. You can save this object for later use and invoke `respond` again in
order to change how a matched request is handled. See #when for more info.