Skip to content

Commit

Permalink
Resolve redirected URLs & case-insensitive input type.
Browse files Browse the repository at this point in the history
  • Loading branch information
rchipka committed Oct 6, 2016
1 parent fc29b42 commit c7e1e0f
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 11 deletions.
2 changes: 0 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,6 @@ Osmosis.prototype.request = function (url, opts, callback, tries) {
self.command.log('[redirect] ' +
url.href + ' -> ' + new_url);
}

url.href = new_url;
});
};

Expand Down
6 changes: 4 additions & 2 deletions lib/Command.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ var Data = require('./Data.js'),
*/

function Command(parent) {
var self = this;

if (Object.getPrototypeOf(parent) === Command.prototype) {
// parent is a Command
this.prev = parent;
Expand Down Expand Up @@ -98,8 +100,8 @@ Command.prototype = {
}
};

Command.prototype.run = function () {
return this.instance.run();
Command.prototype.run = function (context, data) {
return this.instance.run(context, data);
};

/**
Expand Down
8 changes: 5 additions & 3 deletions lib/Data.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ Data.prototype.getObject = function () {
*/

Data.prototype.setObject = function (object) {
return (this.object = object);
this.object = object;

return this;
};

/**
Expand Down Expand Up @@ -244,10 +246,10 @@ Data.prototype.toArray = function () {
return object;
}

if (object === undefined) {
if (this.isEmpty()) {
this.setObject([]);
} else {
this.setObject([object]);
this.setObject([ object ]);
}

return this.getObject();
Expand Down
3 changes: 2 additions & 1 deletion lib/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ form.getParams = function (node) {
value = input.textContent;
break;
case 'input':
switch (input.getAttribute('type')) {
switch (input.getAttribute('type').toLowerCase()) {
case 'radio':
case 'checkbox':
if (!input.hasAttribute('checked')) {
break;
Expand Down
2 changes: 1 addition & 1 deletion lib/Request.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function Request(method, url, params, opts, tries, callback) {
callback(null, res, document);
})
.on('redirect', function (href) {
extend(location, URL.parse(href));
extend(location, URL.parse(URL.resolve(location.href, href)));
});
}

Expand Down
3 changes: 1 addition & 2 deletions lib/commands/then.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ function Then(callback, getContext) {

getContext(context, function (context) {
callback.call(self, context, data.getObject(), function (c, d) {
data.setObject(d);
next(c, data);
next(c, data.setObject(d));

if (length === 3 && calledDone === false) {
process.nextTick(done);
Expand Down
5 changes: 5 additions & 0 deletions test/submit.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ var URL = require('url');

var url = server.host + ':' + server.port;

/*
* TODO: Add radio button tests
* Add input[name] case-insensitivity tests
*/

module.exports.form1 = function (assert) {
var calledThen = false;

Expand Down

0 comments on commit c7e1e0f

Please sign in to comment.