Normalize line endings client side
This commit is contained in:
parent
a279e195be
commit
e027c71341
2 changed files with 2 additions and 4 deletions
3
main.go
3
main.go
|
|
@ -65,9 +65,6 @@ func processCommand(controller Controller, command string) error {
|
||||||
}
|
}
|
||||||
if command[0] == 't' {
|
if command[0] == 't' {
|
||||||
text := command[1:]
|
text := command[1:]
|
||||||
// normalize line endings
|
|
||||||
text = strings.Replace(text, "\r\n", "\n", -1)
|
|
||||||
text = strings.Replace(text, "\r", "\n", -1)
|
|
||||||
if !utf8.ValidString(text) {
|
if !utf8.ValidString(text) {
|
||||||
return errors.New("invalid utf-8")
|
return errors.New("invalid utf-8")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -571,7 +571,8 @@ window.addEventListener("load", function() {
|
||||||
});
|
});
|
||||||
document.getElementById("sendbutton").addEventListener("click", function() {
|
document.getElementById("sendbutton").addEventListener("click", function() {
|
||||||
if (keyboardTextarea.value) {
|
if (keyboardTextarea.value) {
|
||||||
ws.send("t" + keyboardTextarea.value);
|
// normalize line endings
|
||||||
|
ws.send("t" + keyboardTextarea.value.replace(/\r\n?/g, "\n"));
|
||||||
keyboardTextarea.value = "";
|
keyboardTextarea.value = "";
|
||||||
keyboardTextarea.oninput();
|
keyboardTextarea.oninput();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue