Skip to content

Commit

Permalink
Merge pull request #2 from mobilusoss/issue-1
Browse files Browse the repository at this point in the history
update lodash, machine
  • Loading branch information
mohemohe authored Nov 11, 2019
2 parents 24ff72e + a2e9d33 commit 6a83b1b
Show file tree
Hide file tree
Showing 4 changed files with 2,141 additions and 5 deletions.
2 changes: 1 addition & 1 deletion machines/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ module.exports = {
fn: function (inputs, exits) {

// Import `lodash`.
var _ = require('@sailshq/lodash');
var _ = require('lodash');

// Use `replace` with a custom replacer function to substitute actual param values for tokens.
var result = inputs.urlTemplate.replace(/(\:[^\/\:\.]+)/g, function ($all, $1){
Expand Down
12 changes: 11 additions & 1 deletion machines/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ module.exports = {

// Import `url`.
var URL = require('url');
var _ = require('lodash');

// Use the `parse` function of the `url` package to get information about the given URL.
var parsedUrl = URL.parse(inputs.url);
Expand All @@ -62,8 +63,17 @@ module.exports = {
}
}

const cleanObject = JSON.parse(JSON.stringify(parsedUrl));
_.keys(cleanObject).forEach(function(key) {
cleanObject[key] = cleanObject[key] || '';
});
delete cleanObject.slashes;
delete cleanObject.host;
delete cleanObject.query;
delete cleanObject.href;

// Return the parsed URL info through the `success` exit.
return exits.success(parsedUrl);
return exits.success(cleanObject);
},

};
Loading

0 comments on commit 6a83b1b

Please sign in to comment.