Added logging, changed some directory structure

This commit is contained in:
2018-01-13 21:33:40 -05:00
parent f079a5f067
commit 8e72ffb917
73656 changed files with 35284 additions and 53718 deletions

View File

@@ -0,0 +1,19 @@
Copyright (C) 2014 Pascal Hartig
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.

View File

@@ -0,0 +1,45 @@
Node DOM URLs
=============
[![Build Status](https://travis-ci.org/passy/node-dom-urls.png)](https://travis-ci.org/passy/node-dom-urls)
[![Code Climate](https://codeclimate.com/github/passy/node-dom-urls.png)](https://codeclimate.com/github/passy/node-dom-urls)
[![Analytics](https://ga-beacon.appspot.com/UA-587894-18/node-dom-urls/readme)](https://github.com/igrigorik/ga-beacon)
A partial implementation of the [W3C URL Spec Draft](https://dvcs.w3.org/hg/url/raw-file/tip/Overview.html) for Node building on top of [URIjs](http://medialize.github.io/URI.js/).
If you find incompatibilities, please [report them](https://github.com/passy/node-dom-urls/issues). Error handling is currently very different from the spec.
Browser Polyfills
-----------------
- [Joshua Bell's Polyfill](https://github.com/inexorabletash/polyfill/blob/master/url.js)
- [Eric Arvidsson's Polyfill](https://github.com/arv/DOM-URL-Polyfill)
Installation
------------
`npm install dom-urls`
Example
-------
```js
var URL = require('dom-urls');
var url = new URL('relative', 'http://example.com/sub/');
url.protocol; // 'http:'
url.hostname; // 'example.com'
url.pathname; // '/sub/relative/'
url.host = 'example.net:8080';
url.port; // '8080'
```
Why `urijs` instead of `url`?
-----------------------------
I tried it first, but Node's own URL module doesn't propagate changes, so
changing the `host` doesn't affect the port and vice-versa and I didn't want to
reimplement all of that myself.

View File

@@ -0,0 +1,105 @@
'use strict';
var URI = require('urijs');
function URL(urlStr, base) {
if (!urlStr) {
throw new TypeError('You need to provide a URL');
}
this._url = URI(urlStr, base).normalize();
if (!this._url.protocol()) {
throw new SyntaxError('Failed to construct \'URL\': Invalid URL');
}
}
URL.prototype = {
toString: function () {
return this.href;
},
get protocol() {
// Spec wants the trailing colon. (See 5.2)
return this._url.protocol() + ':';
},
set protocol(value) {
// Strip the colon, including anything following it and replace it with a
// single one.
this._url.protocol(value.replace(/(\:.*)?$/, ':'));
},
get host() {
return this._url.clone().normalizeHostname().host();
},
set host(value) {
var partial = new URI('proto://' + value);
var oldPort = this._url.port();
// For some reason, we have to keep the port even though we override the
// complete host (not just the hostname) to not have one according to the
// spec.
this._url.host(value);
if (!partial.port()) {
this._url.port(oldPort);
}
},
get pathname() {
return this._url.pathname();
},
set pathname(value) {
this._url.pathname(value);
this._url.normalizePathname();
},
get path() {
return this._url.path();
},
set path(value) {
this._url.path(value);
this._url.normalizePath();
},
// Origin is a read-only attribute:
// http://url.spec.whatwg.org/#api
get origin() {
// "Let uri-scheme be the scheme component of the URI,
// converted to lowercase."
var scheme = this._url.protocol().toLowerCase();
var hostname = this._url.hostname().toLowerCase();
var port = '';
if (this._url._parts.port !== null &&
this._url._parts.port !== URI.defaultPorts[this._url.protocol()]) {
port = ':' + this._url.port();
}
return scheme + '://' + hostname + port;
}
};
[
'href',
'hostname',
'port',
'search',
'hash'
].forEach(function (property) {
Object.defineProperty(URL.prototype, property, {
get: function () {
return this._url.clone().normalize()[property]();
},
set: function (value) {
this._url[property](value);
}
});
});
module.exports = URL;

View File

@@ -0,0 +1,69 @@
{
"_args": [
[
"dom-urls@1.1.0",
"C:\\Users\\deranjer\\go\\src\\github.com\\deranjer\\goTorrent\\torrent-project"
]
],
"_from": "dom-urls@1.1.0",
"_id": "dom-urls@1.1.0",
"_inBundle": false,
"_integrity": "sha1-AB3fgWKM0ecGElxxdvU8zsVdkY4=",
"_location": "/react-scripts/dom-urls",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "dom-urls@1.1.0",
"name": "dom-urls",
"escapedName": "dom-urls",
"rawSpec": "1.1.0",
"saveSpec": null,
"fetchSpec": "1.1.0"
},
"_requiredBy": [
"/react-scripts/sw-precache"
],
"_resolved": "https://registry.npmjs.org/dom-urls/-/dom-urls-1.1.0.tgz",
"_spec": "1.1.0",
"_where": "C:\\Users\\deranjer\\go\\src\\github.com\\deranjer\\goTorrent\\torrent-project",
"author": {
"name": "Pascal Hartig",
"email": "passy@twitter.com",
"url": "http://passy.me/"
},
"bugs": {
"url": "https://github.com/passy/node-dom-urls/issues"
},
"dependencies": {
"urijs": "^1.16.1"
},
"description": "DOM URLs for Node",
"devDependencies": {
"chai": "^3.3.0",
"mocha": "^2.3.3"
},
"engines": {
"node": ">=0.8.0"
},
"files": [
"index.js"
],
"homepage": "https://github.com/passy/node-dom-urls#readme",
"keywords": [
"dom",
"url",
"urls"
],
"license": "MIT",
"main": "index.js",
"name": "dom-urls",
"repository": {
"type": "git",
"url": "git://github.com/passy/node-dom-urls.git"
},
"scripts": {
"test": "mocha -u tdd"
},
"version": "1.1.0"
}