Closed okamuuu closed 8 years ago
I want to do inlining a local html file. but the html has some external absolute links. inliner.get happens error INVALID URL in this situation.
inliner.get
I resoved the problem with overwrite Inliner.prototyep.resolve as follows:
Inliner.prototyep.resolve
const path = require('path'); const Inliner = require('inliner'); // add let baseURL; Inliner.prototype.resolve = (from, to) => { if (!to) { to = from; from = this.url; } // add if (this.baseURL) { from = this.baseURL; } ... } // this is my own code myinline = (html, opts, callback) => { baseURL = opts.baseURL; new Inliner(url, (err, result) => { if (err) { return callback(err); } callback(null, result); }); }
this way is working. but actually, I want new argument baseURL.
baseURL
var Inliner = require('./lib/index'); new Inliner('<html><head><link rel="stylesheet" href="/simple.css" /></head><body></body></html>', {baseURL: 'http://localhost:8000'}, function (err, html) { console.log(html); // <html><head><style>body{ color:#333;}</style></head><body></body></html> });
So I suggest this PR. Please check it if you think it is worth.
I found bug.. so I close this.
I want to do inlining a local html file. but the html has some external absolute links.
inliner.get
happens error INVALID URL in this situation.I resoved the problem with overwrite
Inliner.prototyep.resolve
as follows:this way is working. but actually, I want new argument
baseURL
.So I suggest this PR. Please check it if you think it is worth.