Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

valid-data-url

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

valid-data-url - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

9

CHANGELOG.md
<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)

7

index.js
'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;

2

package.json
{
"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',

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc