()
| 47 | } |
| 48 | |
| 49 | toString(): string { |
| 50 | let cmdStr = CMD_PREFIX + this.command |
| 51 | |
| 52 | if (this.properties && Object.keys(this.properties).length > 0) { |
| 53 | cmdStr += ' ' |
| 54 | for (const key in this.properties) { |
| 55 | if (this.properties.hasOwnProperty(key)) { |
| 56 | const val = this.properties[key] |
| 57 | if (val) { |
| 58 | // safely append the val - avoid blowing up when attempting to |
| 59 | // call .replace() if message is not a string for some reason |
| 60 | cmdStr += `${key}=${escape(`${val || ''}`)};` |
| 61 | } |
| 62 | } |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | cmdStr += ']' |
| 67 | |
| 68 | // safely append the message - avoid blowing up when attempting to |
| 69 | // call .replace() if message is not a string for some reason |
| 70 | const message = `${this.message || ''}` |
| 71 | cmdStr += escapeData(message) |
| 72 | |
| 73 | return cmdStr |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | function escapeData(s: string): string { |
no test coverage detected