Sha256: 389278066132c8777ecdeae9d9e5de563b66d5ec0b5c7f94470f5f49da60736a

Contents?: true

Size: 1.31 KB

Versions: 39

Compression:

Stored size: 1.31 KB

Contents

getJasmineRequireObj().AjaxParamParser = function() {
  function ParamParser() {
    var defaults = [
      {
        test: function(xhr) {
          return (/^application\/json/).test(xhr.contentType());
        },
        parse: function jsonParser(paramString) {
          return JSON.parse(paramString);
        }
      },
      {
        test: function(xhr) {
          return true;
        },
        parse: function naiveParser(paramString) {
          var data = {};
          var params = paramString.split('&');

          for (var i = 0; i < params.length; ++i) {
            var kv = params[i].replace(/\+/g, ' ').split('=');
            var key = decodeURIComponent(kv[0]);
            data[key] = data[key] || [];
            data[key].push(decodeURIComponent(kv[1]));
          }
          return data;
        }
      }
    ];
    var paramParsers = [];

    this.add = function(parser) {
      paramParsers.unshift(parser);
    };

    this.findParser = function(xhr) {
        for(var i in paramParsers) {
          var parser = paramParsers[i];
          if (parser.test(xhr)) {
            return parser;
          }
        }
    };

    this.reset = function() {
      paramParsers = [];
      for(var i in defaults) {
        paramParsers.push(defaults[i]);
      }
    };

    this.reset();
  }

  return ParamParser;
};

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
upjs-rails-0.11.0 spec_app/vendor/assets/bower_components/jasmine-ajax/src/paramParser.js
upjs-rails-0.10.5 spec_app/vendor/assets/bower_components/jasmine-ajax/src/paramParser.js
upjs-rails-0.10.4 spec_app/vendor/assets/bower_components/jasmine-ajax/src/paramParser.js
upjs-rails-0.10.3 spec_app/vendor/assets/bower_components/jasmine-ajax/src/paramParser.js
upjs-rails-0.10.2 spec_app/vendor/assets/bower_components/jasmine-ajax/src/paramParser.js
upjs-rails-0.10.1 spec_app/vendor/assets/bower_components/jasmine-ajax/src/paramParser.js
upjs-rails-0.10.0 spec_app/vendor/assets/bower_components/jasmine-ajax/src/paramParser.js
upjs-rails-0.9.1 spec_app/vendor/assets/bower_components/jasmine-ajax/src/paramParser.js
upjs-rails-0.9.0 spec_app/vendor/assets/bower_components/jasmine-ajax/src/paramParser.js
upjs-rails-0.8.2 spec_app/vendor/assets/bower_components/jasmine-ajax/src/paramParser.js
upjs-rails-0.8.1 spec_app/vendor/assets/bower_components/jasmine-ajax/src/paramParser.js
upjs-rails-0.8.0 spec_app/vendor/assets/bower_components/jasmine-ajax/src/paramParser.js
upjs-rails-0.7.8 spec_app/vendor/assets/bower_components/jasmine-ajax/src/paramParser.js
upjs-rails-0.7.7 spec_app/vendor/assets/bower_components/jasmine-ajax/src/paramParser.js
upjs-rails-0.7.6 spec_app/vendor/assets/bower_components/jasmine-ajax/src/paramParser.js
upjs-rails-0.7.5 spec_app/vendor/assets/bower_components/jasmine-ajax/src/paramParser.js
upjs-rails-0.7.4 spec_app/vendor/assets/bower_components/jasmine-ajax/src/paramParser.js
upjs-rails-0.7.3 spec_app/vendor/assets/bower_components/jasmine-ajax/src/paramParser.js
upjs-rails-0.7.2 spec_app/vendor/assets/bower_components/jasmine-ajax/src/paramParser.js
upjs-rails-0.7.1 spec_app/vendor/assets/bower_components/jasmine-ajax/src/paramParser.js