electron-html-to
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -5,3 +5,6 @@ /* eslint no-var: [0] */ | ||
var CUSTOM_PROTOCOL = 'electron-html-to'; | ||
var path = require('path'), | ||
fs = require('fs'), | ||
mime = require('mime-types'), | ||
CUSTOM_PROTOCOL = 'electron-html-to'; | ||
@@ -26,4 +29,5 @@ function isURLEncoded(url) { | ||
protocol.registerFileProtocol(CUSTOM_PROTOCOL, function (request, callback) { | ||
var url = request.url.substr(CUSTOM_PROTOCOL.length + 3); | ||
protocol.registerBufferProtocol(CUSTOM_PROTOCOL, function (request, callback) { | ||
var url = request.url.substr(CUSTOM_PROTOCOL.length + 3), | ||
mimeType; | ||
@@ -40,4 +44,13 @@ log(CUSTOM_PROTOCOL + ' file protocol request for:', request.url); | ||
log('handling ' + CUSTOM_PROTOCOL + ' file protocol request. response file path:', url); | ||
callback({ path: url }); | ||
mimeType = mime.lookup(path.extname(url)) || 'text/plain'; | ||
log('handling ' + CUSTOM_PROTOCOL + ' file protocol request. response file path:', url, ', mime:', mimeType); | ||
fs.readFile(url, function (err, buf) { | ||
if (err) { | ||
return callback(); | ||
} | ||
callback({ data: buf, mimeType: mimeType }); | ||
}); | ||
}, function (registerProtocolErr) { | ||
@@ -44,0 +57,0 @@ protocolsCompleted++; |
{ | ||
"name": "electron-html-to", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Convert html to html/image using electron", | ||
@@ -35,2 +35,3 @@ "main": "lib/index.js", | ||
"lodash.pick": "3.1.0", | ||
"mime-types": "2.1.8", | ||
"minstache": "1.2.0", | ||
@@ -37,0 +38,0 @@ "mkdirp": "0.5.1", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
61603
1236
12
21
+ Addedmime-types@2.1.8
+ Addedmime-db@1.20.0(transitive)
+ Addedmime-types@2.1.8(transitive)