url-loader
Advanced tools
Comparing version 0.5.9 to 0.6.0
@@ -5,2 +5,18 @@ # Change Log | ||
<a name="0.6.0"></a> | ||
# [0.6.0](https://github.com/webpack-contrib/url-loader/compare/v0.5.9...v0.6.0) (2017-10-03) | ||
### Features | ||
* **index:** add options validation (`schema-utils`) ([#78](https://github.com/webpack-contrib/url-loader/issues/78)) ([ced5990](https://github.com/webpack-contrib/url-loader/commit/ced5990)) | ||
* add `fallback` option ([#88](https://github.com/webpack-contrib/url-loader/issues/88)) ([636ebed](https://github.com/webpack-contrib/url-loader/commit/636ebed)) | ||
### Security | ||
* Updates Mime pacakge due to Regex DOS security vulnerability ([#87](https://github.com/webpack-contrib/url-loader/issues/87)) ([d19ee2d](https://github.com/webpack-contrib/url-loader/commit/d19ee2d)) | ||
- Reference issue https://nodesecurity.io/advisories/535 | ||
<a name="0.5.9"></a> | ||
@@ -7,0 +23,0 @@ ## [0.5.9](https://github.com/webpack/url-loader/compare/v0.5.8...v0.5.9) (2017-06-12) |
38
index.js
@@ -6,30 +6,36 @@ /* | ||
var loaderUtils = require("loader-utils"); | ||
var validateOptions = require("schema-utils"); | ||
var mime = require("mime"); | ||
module.exports = function(content) { | ||
this.cacheable && this.cacheable(); | ||
this.cacheable && this.cacheable(); | ||
var options = loaderUtils.getOptions(this) || {}; | ||
// Options `dataUrlLimit` is backward compatibility with first loader versions | ||
var limit = options.limit || (this.options && this.options.url && this.options.url.dataUrlLimit); | ||
var options = loaderUtils.getOptions(this) || {}; | ||
if(limit) { | ||
limit = parseInt(limit, 10); | ||
} | ||
validateOptions(require("./options"), options, "URL Loader") | ||
// Options `dataUrlLimit` is backward compatibility with first loader versions | ||
var limit = options.limit || (this.options && this.options.url && this.options.url.dataUrlLimit); | ||
var mimetype = options.mimetype || options.minetype || mime.lookup(this.resourcePath); | ||
if(limit) { | ||
limit = parseInt(limit, 10); | ||
} | ||
// No limits or limit more than content length | ||
if(!limit || content.length < limit) { | ||
if(typeof content === "string") { | ||
content = new Buffer(content); | ||
} | ||
return "module.exports = " + JSON.stringify("data:" + (mimetype ? mimetype + ";" : "") + "base64," + content.toString("base64")); | ||
var mimetype = options.mimetype || options.minetype || mime.lookup(this.resourcePath); | ||
// No limits or limit more than content length | ||
if(!limit || content.length < limit) { | ||
if(typeof content === "string") { | ||
content = new Buffer(content); | ||
} | ||
var fileLoader = require("file-loader"); | ||
return "module.exports = " + JSON.stringify("data:" + (mimetype ? mimetype + ";" : "") + "base64," + content.toString("base64")); | ||
} | ||
return fileLoader.call(this, content); | ||
var fallback = options.fallback || "file-loader"; | ||
var fallbackLoader = require(fallback); | ||
return fallbackLoader.call(this, content); | ||
} | ||
module.exports.raw = true; |
{ | ||
"name": "url-loader", | ||
"version": "0.5.9", | ||
"version": "0.6.0", | ||
"author": "Tobias Koppers @sokra", | ||
@@ -12,3 +12,4 @@ "description": "url loader module for webpack", | ||
"loader-utils": "^1.0.2", | ||
"mime": "1.3.x" | ||
"mime": "^1.4.1", | ||
"schema-utils": "^0.3.0" | ||
}, | ||
@@ -23,4 +24,8 @@ "devDependencies": { | ||
"type": "git", | ||
"url": "git@github.com:webpack/url-loader.git" | ||
} | ||
"url": "git+https://github.com/webpack-contrib/url-loader.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/webpack-contrib/url-loader/issues" | ||
}, | ||
"homepage": "https://github.com/webpack-contrib/url-loader" | ||
} |
@@ -41,6 +41,6 @@ [![npm][npm]][npm-url] | ||
{ | ||
loader: 'url-loader' | ||
loader: 'url-loader', | ||
options: { | ||
limit: 8192 | ||
} | ||
} | ||
} | ||
@@ -60,7 +60,8 @@ ] | ||
|**`mimetype`**|`{String}`|`extname`|Specify MIME type for the file (Otherwise it's inferred from the file extension)| | ||
|**`prefix`**|`{String}`|`false`|Parameters for the [`file-loader`](https://github.com/webpack-contrib/file-loader) are valid too. They are passed to the file-loader if used| | ||
|**`fallback`**|`{String}`|`file-loader`|Specify `loader` for the file when file is greater than the limit (in bytes)| | ||
### `limit` | ||
If the file is greater than the limit (in bytes) the [`file-loader`](https://github.com/webpack-contrib/file-loader) is used and all query parameters are passed to it. | ||
If the file is greater than the limit (in bytes) the [`file-loader`](https://github.com/webpack-contrib/file-loader) is used by default and all query parameters are passed to it. | ||
You can use other loader using `fallback` option. | ||
@@ -93,4 +94,5 @@ The limit can be specified via loader options and defaults to no limit. | ||
### `prefix` | ||
### `fallback` | ||
**webpack.config.js** | ||
```js | ||
@@ -100,3 +102,3 @@ { | ||
options: { | ||
prefix: 'img' | ||
fallback: 'responsive-loader' | ||
} | ||
@@ -103,0 +105,0 @@ } |
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
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
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
10659
47
0
1
166
4
1
+ Addedschema-utils@^0.3.0
+ Addedajv@5.5.2(transitive)
+ Addedco@4.6.0(transitive)
+ Addedfast-deep-equal@1.1.0(transitive)
+ Addedjson-schema-traverse@0.3.1(transitive)
+ Addedmime@1.6.0(transitive)
+ Addedschema-utils@0.3.0(transitive)
- Removedmime@1.3.6(transitive)
Updatedmime@^1.4.1