-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from trs/fix-utf8
Fix utf8
- Loading branch information
Showing
18 changed files
with
188 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,34 @@ | ||
const _ = require('lodash'); | ||
|
||
const OPTIONS = { | ||
UTF8: utf8, | ||
'UTF-8': utf8 | ||
}; | ||
|
||
module.exports = { | ||
directive: 'OPTS', | ||
handler: function () { | ||
return this.reply(501); | ||
handler: function ({command} = {}) { | ||
if (!_.has(command, 'arg')) return this.reply(501); | ||
|
||
const [_option, ...args] = command.arg.split(' '); | ||
const option = _.toUpper(_option); | ||
|
||
if (!OPTIONS.hasOwnProperty(option)) return this.reply(500); | ||
return OPTIONS[option].call(this, args); | ||
}, | ||
syntax: '{{cmd}}', | ||
description: 'Select options for a feature' | ||
}; | ||
|
||
function utf8([setting] = []) { | ||
switch (_.toUpper(setting)) { | ||
case 'ON': | ||
this.encoding = 'utf8'; | ||
return this.reply(200, 'UTF8 encoding on'); | ||
case 'OFF': | ||
this.encoding = 'ascii'; | ||
return this.reply(200, 'UTF8 encoding off'); | ||
default: | ||
return this.reply(501, 'Unknown setting for option'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const _ = require('lodash'); | ||
|
||
module.exports = { | ||
directive: 'REST', | ||
handler: function ({command} = {}) { | ||
const arg = _.get(command, 'arg'); | ||
const byteCount = parseInt(arg, 10); | ||
|
||
if (isNaN(byteCount) || byteCount < 0) return this.reply(501, 'Byte count must be 0 or greater'); | ||
|
||
this.restByteCount = byteCount; | ||
return this.reply(350, `Resarting next transfer at ${byteCount}`); | ||
}, | ||
syntax: '{{cmd}} <byte-count>', | ||
description: 'Restart transfer from the specified point. Resets after any STORE or RETRIEVE' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.