Welis Garagen-Anzeige

This commit is contained in:
2018-02-04 20:14:45 +01:00
parent 9b4b42bdc0
commit 48d7ac9661
855 changed files with 134068 additions and 5 deletions
+1
View File
@@ -0,0 +1 @@
/node_modules
+20
View File
@@ -0,0 +1,20 @@
0.0.3 / 2014-01-08
==================
* index: fix a URI with a comma in the data portion
0.0.2 / 2014-01-08
==================
* index: use unescape() instead of decodeURIComponent()
* test: add more tests from Mozilla
0.0.1 / 2014-01-02
==================
* add `README.md`
* index: default the `charset` property to "US-ASCII"
* default encoding is "ascii"
* default `type` to "text/plain" when none is given
* initial commit
+57
View File
@@ -0,0 +1,57 @@
data-uri-to-buffer
==================
### Generate a Buffer instance from a Data URI string
[![Build Status](https://travis-ci.org/TooTallNate/data-uri-to-buffer.png?branch=master)](https://travis-ci.org/TooTallNate/data-uri-to-buffer)
Installation
------------
Install with `npm`:
``` bash
$ npm install data-uri-to-buffer
```
Example
-------
``` js
var dataUriToBuffer = require('data-uri-to-buffer');
```
API
---
### dataUriToBuffer(String uri) → Buffer
License
-------
(The MIT License)
Copyright (c) 2014 Nathan Rajlich <nathan@tootallnate.net>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+54
View File
@@ -0,0 +1,54 @@
/**
* Module exports.
*/
module.exports = dataUriToBuffer;
/**
* Returns a `Buffer` instance from the given data URI `uri`.
*
* @param {String} uri Data URI to turn into a Buffer instance
* @return {Buffer} Buffer instance from Data URI
* @api public
*/
function dataUriToBuffer (uri) {
if (!/^data\:/i.test(uri)) {
throw new TypeError('`uri` does not appear to be a Data URI (must begin with "data:")');
}
// strip newlines
uri = uri.replace(/\r?\n/g, '');
// split the URI up into the "metadata" and the "data" portions
var firstComma = uri.indexOf(',');
if (-1 === firstComma || firstComma <= 4) throw new TypeError('malformed data: URI');
// remove the "data:" scheme and parse the metadata
var meta = uri.substring(5, firstComma).split(';');
var base64 = false;
var charset = 'US-ASCII';
for (var i = 0; i < meta.length; i++) {
if ('base64' == meta[i]) {
base64 = true;
} else if (0 == meta[i].indexOf('charset=')) {
charset = meta[i].substring(8);
}
}
// get the encoded data portion and decode URI-encoded chars
var data = unescape(uri.substring(firstComma + 1));
var encoding = base64 ? 'base64' : 'ascii';
var buffer = new Buffer(data, encoding);
// set `.type` property to MIME type
buffer.type = meta[0] || 'text/plain';
// set the `.charset` property
buffer.charset = charset;
return buffer;
}
+92
View File
@@ -0,0 +1,92 @@
{
"_args": [
[
{
"raw": "data-uri-to-buffer@0.0.3",
"scope": null,
"escapedName": "data-uri-to-buffer",
"name": "data-uri-to-buffer",
"rawSpec": "0.0.3",
"spec": "0.0.3",
"type": "version"
},
"/Users/gerrit/Documents/node.js-Projects/tinkerforge/node_modules/get-pixels"
]
],
"_from": "data-uri-to-buffer@0.0.3",
"_id": "data-uri-to-buffer@0.0.3",
"_inCache": true,
"_location": "/data-uri-to-buffer",
"_npmUser": {
"name": "tootallnate",
"email": "nathan@tootallnate.net"
},
"_npmVersion": "1.3.21",
"_phantomChildren": {},
"_requested": {
"raw": "data-uri-to-buffer@0.0.3",
"scope": null,
"escapedName": "data-uri-to-buffer",
"name": "data-uri-to-buffer",
"rawSpec": "0.0.3",
"spec": "0.0.3",
"type": "version"
},
"_requiredBy": [
"/get-pixels",
"/parse-data-uri"
],
"_resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-0.0.3.tgz",
"_shasum": "18ae979a6a0ca994b0625853916d2662bbae0b1a",
"_shrinkwrap": null,
"_spec": "data-uri-to-buffer@0.0.3",
"_where": "/Users/gerrit/Documents/node.js-Projects/tinkerforge/node_modules/get-pixels",
"author": {
"name": "Nathan Rajlich",
"email": "nathan@tootallnate.net",
"url": "http://n8.io/"
},
"bugs": {
"url": "https://github.com/TooTallNate/node-data-uri-to-buffer/issues"
},
"dependencies": {},
"description": "Generate a Buffer instance from a Data URI string",
"devDependencies": {
"mocha": "~1.16.2"
},
"directories": {
"test": "test"
},
"dist": {
"shasum": "18ae979a6a0ca994b0625853916d2662bbae0b1a",
"tarball": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-0.0.3.tgz"
},
"homepage": "https://github.com/TooTallNate/node-data-uri-to-buffer",
"keywords": [
"data",
"uri",
"datauri",
"data-uri",
"buffer",
"convert"
],
"license": "MIT",
"main": "index.js",
"maintainers": [
{
"name": "tootallnate",
"email": "nathan@tootallnate.net"
}
],
"name": "data-uri-to-buffer",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git://github.com/TooTallNate/node-data-uri-to-buffer.git"
},
"scripts": {
"test": "mocha --reporter spec"
},
"version": "0.0.3"
}
+121
View File
@@ -0,0 +1,121 @@
/**
* Module dependencies.
*/
var assert = require('assert');
var dataUriToBuffer = require('../');
describe('data-uri-to-buffer', function () {
it('should decode bare-bones Data URIs', function () {
var uri = 'data:,Hello%2C%20World!';
var buf = dataUriToBuffer(uri);
assert.equal('text/plain', buf.type);
assert.equal('Hello, World!', buf.toString());
});
it('should decode bare-bones "base64" Data URIs', function () {
var uri = 'data:text/plain;base64,SGVsbG8sIFdvcmxkIQ%3D%3D';
var buf = dataUriToBuffer(uri);
assert.equal('text/plain', buf.type);
assert.equal('Hello, World!', buf.toString());
});
it('should decode plain-text Data URIs', function () {
var html = '<!DOCTYPE html>'+
'<html lang="en">'+
'<head><title>Embedded Window</title></head>'+
'<body><h1>42</h1></body>'+
'</html>';
// Escape the HTML for URL formatting
var uri = 'data:text/html;charset=utf-8,' + encodeURIComponent(html);
var buf = dataUriToBuffer(uri);
assert.equal('text/html', buf.type);
assert.equal('utf-8', buf.charset);
assert.equal(html, buf.toString());
});
// the next 4 tests are from:
// https://bug161965.bugzilla.mozilla.org/attachment.cgi?id=94670&action=view
it('should decode "ISO-8859-8 in Base64" URIs', function () {
var uri = 'data:text/plain;charset=iso-8859-8-i;base64,+ezl7Q==';
var buf = dataUriToBuffer(uri);
assert.equal('text/plain', buf.type);
assert.equal('iso-8859-8-i', buf.charset);
assert.equal(4, buf.length);
assert.equal(0xf9, buf[0]);
assert.equal(0xec, buf[1]);
assert.equal(0xe5, buf[2]);
assert.equal(0xed, buf[3]);
});
it('should decode "ISO-8859-8 in URL-encoding" URIs', function () {
var uri = 'data:text/plain;charset=iso-8859-8-i,%f9%ec%e5%ed';
var buf = dataUriToBuffer(uri);
assert.equal('text/plain', buf.type);
assert.equal('iso-8859-8-i', buf.charset);
assert.equal(4, buf.length);
assert.equal(0xf9, buf[0]);
assert.equal(0xec, buf[1]);
assert.equal(0xe5, buf[2]);
assert.equal(0xed, buf[3]);
});
it('should decode "UTF-8 in Base64" URIs', function () {
var uri = 'data:text/plain;charset=UTF-8;base64,16nXnNeV150=';
var buf = dataUriToBuffer(uri);
assert.equal('text/plain', buf.type);
assert.equal('UTF-8', buf.charset);
assert.equal(8, buf.length);
assert.equal('שלום', buf.toString('utf8'));
});
it('should decode "UTF-8 in URL-encoding" URIs', function () {
var uri = 'data:text/plain;charset=UTF-8,%d7%a9%d7%9c%d7%95%d7%9d';
var buf = dataUriToBuffer(uri);
assert.equal('text/plain', buf.type);
assert.equal('UTF-8', buf.charset);
assert.equal(8, buf.length);
assert.equal('שלום', buf.toString('utf8'));
});
// this next one is from Wikipedia IIRC
it('should decode "base64" Data URIs with newlines', function () {
var uri = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA\n' +
'AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO\n' +
'9TXL0Y4OHwAAAABJRU5ErkJggg==';
var buf = dataUriToBuffer(uri);
assert.equal('image/png', buf.type);
assert.equal('iVBORw0KGgoAAAANSUhEUgAAAAUA' +
'AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO' +
'9TXL0Y4OHwAAAABJRU5ErkJggg==', buf.toString('base64'));
});
it('should decode a plain-text URI with a space character in it', function () {
var uri = 'data:,foo bar';
var buf = dataUriToBuffer(uri);
assert.equal('text/plain', buf.type);
assert.equal('foo bar', buf.toString());
});
it('should take "data" segment after the first comma', function () {
var uri = 'data:,a,b';
var buf = dataUriToBuffer(uri);
assert.equal('text/plain', buf.type);
assert.equal('a,b', buf.toString());
});
});