valid-data-url
Advanced tools
Comparing version 0.1.2 to 0.1.3
<a name="0.1.3"></a> | ||
### 0.1.3 (2016-10-22) | ||
* accept types with a `.` character like `application/vnd.ms-excel` | ||
* removed some unnecessary backslashes (`\`) | ||
<a name="0.1.2"></a> | ||
@@ -7,2 +14,3 @@ ### 0.1.2 (2016-10-21) | ||
<a name="0.1.1"></a> | ||
@@ -13,2 +21,3 @@ ### 0.1.1 (2016-05-09) | ||
<a name="0.1.0"></a> | ||
@@ -15,0 +24,0 @@ ### 0.1.0 (2016-05-09) |
'use strict'; | ||
// Detecting data URLs | ||
// data URI - MDN https://developer.mozilla.org/en-US/docs/data_URIs | ||
// The "data" URL scheme: http://tools.ietf.org/html/rfc2397 | ||
// Valid URL Characters: http://tools.ietf.org/html/rfc2396#section2 | ||
function validDataUrl(s) { | ||
return validDataUrl.regex.test(s); | ||
} | ||
validDataUrl.regex = /^\s*data:([a-z]+\/[a-z0-9\-\+]+(;[a-z\-]+\=[a-z0-9\-]+)?)?(;base64)?,([a-z0-9\!\$\&\'\,\(\)\*\+\,\;\=\-\.\_\~\:\@\/\?\%\s]*?)\s*$/i; | ||
validDataUrl.regex = /^\s*data:([a-z]+\/[a-z0-9-+.]+(;[a-z-]+=[a-z0-9-]+)?)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s]*?)\s*$/i; | ||
module.exports = validDataUrl; |
{ | ||
"name": "valid-data-url", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "Detect if a string is a data URL", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -53,3 +53,4 @@ # Detect if a string is a data URL | ||
- [Steve Powell](https://github.com/steve-p-com) | ||
- [Rob G](https://github.com/Mottie) | ||
- [Rob Garrison](https://github.com/Mottie) | ||
- [Frank Tan](https://github.com/tansongyang) | ||
@@ -56,0 +57,0 @@ |
@@ -21,4 +21,6 @@ /* globals describe, it */ | ||
'data:audio/mp3;base64,%3Ch1%3EHello!%3C%2Fh1%3E', | ||
'data:video/x-ms-wmv;base64,%3Ch1%3EHello!%3C%2Fh1%3E' | ||
'data:video/x-ms-wmv;base64,%3Ch1%3EHello!%3C%2Fh1%3E', | ||
'data:application/vnd.ms-excel;base64,PGh0bWw%2BPC9odG1sPg%3D%3D' | ||
]; | ||
var invalid = [ | ||
@@ -25,0 +27,0 @@ 'dataxbase64', |
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
10822
106
80