Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. # URI.js
  2. URI.js is an [RFC 3986](http://www.ietf.org/rfc/rfc3986.txt) compliant, scheme extendable URI parsing/validating/resolving library for all JavaScript environments (browsers, Node.js, etc).
  3. It is also compliant with the IRI ([RFC 3987](http://www.ietf.org/rfc/rfc3987.txt)), IDNA ([RFC 5890](http://www.ietf.org/rfc/rfc5890.txt)), IPv6 Address ([RFC 5952](http://www.ietf.org/rfc/rfc5952.txt)), IPv6 Zone Identifier ([RFC 6874](http://www.ietf.org/rfc/rfc6874.txt)) specifications.
  4. URI.js has an extensive test suite, and works in all (Node.js, web) environments. It weighs in at 6.4kb (gzipped, 17kb deflated).
  5. ## API
  6. ### Parsing
  7. URI.parse("uri://user:pass@example.com:123/one/two.three?q1=a1&q2=a2#body");
  8. //returns:
  9. //{
  10. // scheme : "uri",
  11. // userinfo : "user:pass",
  12. // host : "example.com",
  13. // port : 123,
  14. // path : "/one/two.three",
  15. // query : "q1=a1&q2=a2",
  16. // fragment : "body"
  17. //}
  18. ### Serializing
  19. URI.serialize({scheme : "http", host : "example.com", fragment : "footer"}) === "http://example.com/#footer"
  20. ### Resolving
  21. URI.resolve("uri://a/b/c/d?q", "../../g") === "uri://a/g"
  22. ### Normalizing
  23. URI.normalize("HTTP://ABC.com:80/%7Esmith/home.html") === "http://abc.com/~smith/home.html"
  24. ### Comparison
  25. URI.equal("example://a/b/c/%7Bfoo%7D", "eXAMPLE://a/./b/../b/%63/%7bfoo%7d") === true
  26. ### IP Support
  27. //IPv4 normalization
  28. URI.normalize("//192.068.001.000") === "//192.68.1.0"
  29. //IPv6 normalization
  30. URI.normalize("//[2001:0:0DB8::0:0001]") === "//[2001:0:db8::1]"
  31. //IPv6 zone identifier support
  32. URI.parse("//[2001:db8::7%25en1]");
  33. //returns:
  34. //{
  35. // host : "2001:db8::7%en1"
  36. //}
  37. ### IRI Support
  38. //convert IRI to URI
  39. URI.serialize(URI.parse("http://examplé.org/rosé")) === "http://xn--exampl-gva.org/ros%C3%A9"
  40. //convert URI to IRI
  41. URI.serialize(URI.parse("http://xn--exampl-gva.org/ros%C3%A9"), {iri:true}) === "http://examplé.org/rosé"
  42. ### Options
  43. All of the above functions can accept an additional options argument that is an object that can contain one or more of the following properties:
  44. * `scheme` (string)
  45. Indicates the scheme that the URI should be treated as, overriding the URI's normal scheme parsing behavior.
  46. * `reference` (string)
  47. If set to `"suffix"`, it indicates that the URI is in the suffix format, and the validator will use the option's `scheme` property to determine the URI's scheme.
  48. * `tolerant` (boolean, false)
  49. If set to `true`, the parser will relax URI resolving rules.
  50. * `absolutePath` (boolean, false)
  51. If set to `true`, the serializer will not resolve a relative `path` component.
  52. * `iri` (boolean, false)
  53. If set to `true`, the serializer will unescape non-ASCII characters as per [RFC 3987](http://www.ietf.org/rfc/rfc3987.txt).
  54. * `unicodeSupport` (boolean, false)
  55. If set to `true`, the parser will unescape non-ASCII characters in the parsed output as per [RFC 3987](http://www.ietf.org/rfc/rfc3987.txt).
  56. * `domainHost` (boolean, false)
  57. If set to `true`, the library will treat the `host` component as a domain name, and convert IDNs (International Domain Names) as per [RFC 5891](http://www.ietf.org/rfc/rfc5891.txt).
  58. ## Scheme Extendable
  59. URI.js supports inserting custom [scheme](http://en.wikipedia.org/wiki/URI_scheme) dependent processing rules. Currently, URI.js has built in support for the following schemes:
  60. * http \[[RFC 2616](http://www.ietf.org/rfc/rfc2616.txt)\]
  61. * https \[[RFC 2818](http://www.ietf.org/rfc/rfc2818.txt)\]
  62. * ws \[[RFC 6455](http://www.ietf.org/rfc/rfc6455.txt)\]
  63. * wss \[[RFC 6455](http://www.ietf.org/rfc/rfc6455.txt)\]
  64. * mailto \[[RFC 6068](http://www.ietf.org/rfc/rfc6068.txt)\]
  65. * urn \[[RFC 2141](http://www.ietf.org/rfc/rfc2141.txt)\]
  66. * urn:uuid \[[RFC 4122](http://www.ietf.org/rfc/rfc4122.txt)\]
  67. ### HTTP/HTTPS Support
  68. URI.equal("HTTP://ABC.COM:80", "http://abc.com/") === true
  69. URI.equal("https://abc.com", "HTTPS://ABC.COM:443/") === true
  70. ### WS/WSS Support
  71. URI.parse("wss://example.com/foo?bar=baz");
  72. //returns:
  73. //{
  74. // scheme : "wss",
  75. // host: "example.com",
  76. // resourceName: "/foo?bar=baz",
  77. // secure: true,
  78. //}
  79. URI.equal("WS://ABC.COM:80/chat#one", "ws://abc.com/chat") === true
  80. ### Mailto Support
  81. URI.parse("mailto:alpha@example.com,bravo@example.com?subject=SUBSCRIBE&body=Sign%20me%20up!");
  82. //returns:
  83. //{
  84. // scheme : "mailto",
  85. // to : ["alpha@example.com", "bravo@example.com"],
  86. // subject : "SUBSCRIBE",
  87. // body : "Sign me up!"
  88. //}
  89. URI.serialize({
  90. scheme : "mailto",
  91. to : ["alpha@example.com"],
  92. subject : "REMOVE",
  93. body : "Please remove me",
  94. headers : {
  95. cc : "charlie@example.com"
  96. }
  97. }) === "mailto:alpha@example.com?cc=charlie@example.com&subject=REMOVE&body=Please%20remove%20me"
  98. ### URN Support
  99. URI.parse("urn:example:foo");
  100. //returns:
  101. //{
  102. // scheme : "urn",
  103. // nid : "example",
  104. // nss : "foo",
  105. //}
  106. #### URN UUID Support
  107. URI.parse("urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6");
  108. //returns:
  109. //{
  110. // scheme : "urn",
  111. // nid : "uuid",
  112. // uuid : "f81d4fae-7dec-11d0-a765-00a0c91e6bf6",
  113. //}
  114. ## Usage
  115. To load in a browser, use the following tag:
  116. <script type="text/javascript" src="uri-js/dist/es5/uri.all.min.js"></script>
  117. To load in a CommonJS/Module environment, first install with npm/yarn by running on the command line:
  118. npm install uri-js
  119. # OR
  120. yarn add uri-js
  121. Then, in your code, load it using:
  122. const URI = require("uri-js");
  123. If you are writing your code in ES6+ (ESNEXT) or TypeScript, you would load it using:
  124. import * as URI from "uri-js";
  125. Or you can load just what you need using named exports:
  126. import { parse, serialize, resolve, resolveComponents, normalize, equal, removeDotSegments, pctEncChar, pctDecChars, escapeComponent, unescapeComponent } from "uri-js";
  127. ## Breaking changes
  128. ### Breaking changes from 3.x
  129. URN parsing has been completely changed to better align with the specification. Scheme is now always `urn`, but has two new properties: `nid` which contains the Namspace Identifier, and `nss` which contains the Namespace Specific String. The `nss` property will be removed by higher order scheme handlers, such as the UUID URN scheme handler.
  130. The UUID of a URN can now be found in the `uuid` property.
  131. ### Breaking changes from 2.x
  132. URI validation has been removed as it was slow, exposed a vulnerabilty, and was generally not useful.
  133. ### Breaking changes from 1.x
  134. The `errors` array on parsed components is now an `error` string.