Skip to content

Commit

Permalink
#59 Handle newlines correctly for windows platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbyrne01 committed Oct 2, 2014
1 parent 4ec7f75 commit c0f5d7a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
10 changes: 8 additions & 2 deletions lib/Chrome.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ var {Cc,Ci,Cu,components} = require("chrome"),
Tab = require("./Tab"),
Notification = require("./Notification"),
Localisation = require("./Localisation"),
Panel = require("./Panel");
Panel = require("./Panel"),
System = require("./System");

exports.getHomeDir = function() {

Expand Down Expand Up @@ -186,8 +187,13 @@ exports.saveTo = function(selectedText){
string += Tab.getURL() + '\n\n';
}

var combinedString = string + selectedText;

var istream = converter.convertToInputStream(string + selectedText);
if (System.getPlatform().indexOf('win') >= 0){
combinedString = ombinedString.replace(/[\n]/g, '\r\n');
}

var istream = converter.convertToInputStream(combinedString);

// The last argument (the callback) is optional.
NetUtil.asyncCopy(istream, ostream, function(status) {
Expand Down
11 changes: 11 additions & 0 deletions lib/System.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
var system = require("sdk/system")

function getPlatform() {

return system.platform;
}

exports.getPlatform = function() {

return getPlatform();
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "Saves highlighted text to a file in a specified directory",
"author": "Robert Byrne",
"license": "GNU GPL v3",
"version": "2.4.4",
"version": "2.4.5",
"permissions": {"private-browsing": true},
"preferences": [{
"name": "fileName",
Expand Down

0 comments on commit c0f5d7a

Please sign in to comment.