fast-mhtml
Advanced tools
Comparing version 1.1.1 to 1.1.2
{ | ||
"name": "fast-mhtml", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "Parses mhtml files", | ||
"main": "src/index.js", | ||
"types": "src/index.d.ts", | ||
"scripts": { | ||
@@ -7,0 +8,0 @@ "test": "nyc --reporter=html mocha src/*.test.js", |
@@ -148,3 +148,3 @@ const { URL } = require('url'); // url isn't global in Node < 8 | ||
if (attribute === attrs.STYLE) { | ||
value = this.cssProcessor ? this.cssProcessor(fromHtml, this.mapping, this.baseUrl) : fromHtml; | ||
value = this.cssProcessor ? this.cssProcessor(fromHtml, this.mapping, this.baseUrl, true) : fromHtml; | ||
} else if (tagName === 'base') { | ||
@@ -247,2 +247,3 @@ this.baseUrl = new URL(fromHtml, this.baseUrl); | ||
} | ||
/* istanbul ignore next unreachable */ | ||
return false; | ||
@@ -270,3 +271,3 @@ } | ||
} else { // unescaped | ||
while (!isWhitespace(this.current()) && this.lenOk()) { | ||
while (!isWhitespace(this.current()) && !(this.current() === c.ANGLE_CLOSE) && this.lenOk()) { | ||
this.addAndProgress(); | ||
@@ -283,6 +284,6 @@ } | ||
} | ||
this.i++; // rread the quote | ||
this.i++; // read the quote | ||
return this.data.toString('utf8', initial, this.i - 1); | ||
} // unescaped | ||
while (!isWhitespace(this.current()) && this.lenOk()) { | ||
while (!isWhitespace(this.current()) && (this.current() !== c.ANGLE_CLOSE) && this.lenOk()) { | ||
this.i++; | ||
@@ -319,3 +320,3 @@ } | ||
if (isData(data[initial], data[initial + 1], data[initial + 2], data[initial + 3])) { | ||
return attrs.Data; | ||
return attrs.DATA; | ||
} | ||
@@ -322,0 +323,0 @@ return attrs.OTHER; |
@@ -39,3 +39,9 @@ const cheerio = require('cheerio'); | ||
}, | ||
css(cssString, resourcesMap, baseUrl) { | ||
css(cssString, resourcesMap, baseUrl, inAttribute = false) { | ||
let start = "url('"; | ||
let end = "')"; | ||
if (inAttribute) { | ||
start = 'url("'; | ||
end = '")'; | ||
} | ||
return cssString.toString().replace(CSS_REPLACE_RE, (whole, match) => { | ||
@@ -48,3 +54,3 @@ if (match.charAt(0) === '/' && match.charAt(1) === '/') { // protocol agnostic URL | ||
/* eslint-disable prefer-template */ // hot point | ||
return "url('" + mapped + "')"; | ||
return start + mapped + end; | ||
}); | ||
@@ -51,0 +57,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
251332
26
1344