Last active
April 25, 2017 18:14
-
-
Save sunnygleason/31165fa4c4507f9e1ba4f70684a575e0 to your computer and use it in GitHub Desktop.
PubNub HTML Sanitizer BLOCK JavaScript
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
export default (request) => { | |
const xhr = require('xhr'); | |
const query = require('codec/query_string'); | |
const userId = 'YOUR_USER'; | |
const apiKey = 'YOUR_API_KEY'; | |
const outputType = 'plain-text'; | |
let apiUrl = 'https://neutrinoapi.com/html-clean'; | |
let params = { | |
'user-id': userId, | |
'api-key': apiKey, | |
'content': request.message.payload, | |
'output-type': outputType | |
}; | |
apiUrl = apiUrl + '?' + query.stringify(params); | |
return xhr.fetch(apiUrl).then((response) => { | |
request.message.clean_html = response.body; | |
request.message.original_html = request.message.payload; | |
delete request.message.payload; | |
return request.ok(); | |
}).catch(err => { | |
console.error(err); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment