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 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. # normalize-url [![Build Status](https://travis-ci.org/sindresorhus/normalize-url.svg?branch=master)](https://travis-ci.org/sindresorhus/normalize-url) [![Coverage Status](https://coveralls.io/repos/github/sindresorhus/normalize-url/badge.svg?branch=master)](https://coveralls.io/github/sindresorhus/normalize-url?branch=master)
  2. > [Normalize](https://en.wikipedia.org/wiki/URL_normalization) a URL
  3. Useful when you need to display, store, deduplicate, sort, compare, etc, URLs.
  4. ## Install
  5. ```
  6. $ npm install normalize-url
  7. ```
  8. ## Usage
  9. ```js
  10. const normalizeUrl = require('normalize-url');
  11. normalizeUrl('sindresorhus.com');
  12. //=> 'http://sindresorhus.com'
  13. normalizeUrl('HTTP://xn--xample-hva.com:80/?b=bar&a=foo');
  14. //=> 'http://êxample.com/?a=foo&b=bar'
  15. ```
  16. ## API
  17. ### normalizeUrl(url, options?)
  18. #### url
  19. Type: `string`
  20. URL to normalize, including [data URL](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs).
  21. #### options
  22. Type: `object`
  23. ##### defaultProtocol
  24. Type: `string`<br>
  25. Default: `http:`
  26. ##### normalizeProtocol
  27. Type: `boolean`<br>
  28. Default: `true`
  29. Prepend `defaultProtocol` to the URL if it's protocol-relative.
  30. ```js
  31. normalizeUrl('//sindresorhus.com:80/');
  32. //=> 'http://sindresorhus.com'
  33. normalizeUrl('//sindresorhus.com:80/', {normalizeProtocol: false});
  34. //=> '//sindresorhus.com'
  35. ```
  36. ##### forceHttp
  37. Type: `boolean`<br>
  38. Default: `false`
  39. Normalize `https:` to `http:`.
  40. ```js
  41. normalizeUrl('https://sindresorhus.com:80/');
  42. //=> 'https://sindresorhus.com'
  43. normalizeUrl('https://sindresorhus.com:80/', {forceHttp: true});
  44. //=> 'http://sindresorhus.com'
  45. ```
  46. ##### forceHttps
  47. Type: `boolean`<br>
  48. Default: `false`
  49. Normalize `http:` to `https:`.
  50. ```js
  51. normalizeUrl('https://sindresorhus.com:80/');
  52. //=> 'https://sindresorhus.com'
  53. normalizeUrl('http://sindresorhus.com:80/', {forceHttps: true});
  54. //=> 'https://sindresorhus.com'
  55. ```
  56. This option can't be used with the `forceHttp` option at the same time.
  57. ##### stripAuthentication
  58. Type: `boolean`<br>
  59. Default: `true`
  60. Strip the [authentication](https://en.wikipedia.org/wiki/Basic_access_authentication) part of the URL.
  61. ```js
  62. normalizeUrl('user:password@sindresorhus.com');
  63. //=> 'https://sindresorhus.com'
  64. normalizeUrl('user:password@sindresorhus.com', {stripAuthentication: false});
  65. //=> 'https://user:password@sindresorhus.com'
  66. ```
  67. ##### stripHash
  68. Type: `boolean`<br>
  69. Default: `false`
  70. Strip the hash part of the URL.
  71. ```js
  72. normalizeUrl('sindresorhus.com/about.html#contact');
  73. //=> 'http://sindresorhus.com/about.html#contact'
  74. normalizeUrl('sindresorhus.com/about.html#contact', {stripHash: true});
  75. //=> 'http://sindresorhus.com/about.html'
  76. ```
  77. ##### stripProtocol
  78. Type: `boolean`<br>
  79. Default: `false`
  80. Remove HTTP(S) protocol from the URL: `http://sindresorhus.com` → `sindresorhus.com`.
  81. ```js
  82. normalizeUrl('https://sindresorhus.com');
  83. //=> 'https://sindresorhus.com'
  84. normalizeUrl('sindresorhus.com', {stripProtocol: true});
  85. //=> 'sindresorhus.com'
  86. ```
  87. ##### stripWWW
  88. Type: `boolean`<br>
  89. Default: `true`
  90. Remove `www.` from the URL.
  91. ```js
  92. normalizeUrl('http://www.sindresorhus.com');
  93. //=> 'http://sindresorhus.com'
  94. normalizeUrl('http://www.sindresorhus.com', {stripWWW: false});
  95. //=> 'http://www.sindresorhus.com'
  96. ```
  97. ##### removeQueryParameters
  98. Type: `Array<RegExp | string>`<br>
  99. Default: `[/^utm_\w+/i]`
  100. Remove query parameters that matches any of the provided strings or regexes.
  101. ```js
  102. normalizeUrl('www.sindresorhus.com?foo=bar&ref=test_ref', {
  103. removeQueryParameters: ['ref']
  104. });
  105. //=> 'http://sindresorhus.com/?foo=bar'
  106. ```
  107. ##### removeTrailingSlash
  108. Type: `boolean`<br>
  109. Default: `true`
  110. Remove trailing slash.
  111. **Note:** Trailing slash is always removed if the URL doesn't have a pathname.
  112. ```js
  113. normalizeUrl('http://sindresorhus.com/redirect/');
  114. //=> 'http://sindresorhus.com/redirect'
  115. normalizeUrl('http://sindresorhus.com/redirect/', {removeTrailingSlash: false});
  116. //=> 'http://sindresorhus.com/redirect/'
  117. normalizeUrl('http://sindresorhus.com/', {removeTrailingSlash: false});
  118. //=> 'http://sindresorhus.com'
  119. ```
  120. ##### removeDirectoryIndex
  121. Type: `boolean | Array<RegExp | string>`<br>
  122. Default: `false`
  123. Removes the default directory index file from path that matches any of the provided strings or regexes. When `true`, the regex `/^index\.[a-z]+$/` is used.
  124. ```js
  125. normalizeUrl('www.sindresorhus.com/foo/default.php', {
  126. removeDirectoryIndex: [/^default\.[a-z]+$/]
  127. });
  128. //=> 'http://sindresorhus.com/foo'
  129. ```
  130. ##### sortQueryParameters
  131. Type: `boolean`<br>
  132. Default: `true`
  133. Sorts the query parameters alphabetically by key.
  134. ```js
  135. normalizeUrl('www.sindresorhus.com?b=two&a=one&c=three', {
  136. sortQueryParameters: false
  137. });
  138. //=> 'http://sindresorhus.com/?b=two&a=one&c=three'
  139. ```
  140. ## Related
  141. - [compare-urls](https://github.com/sindresorhus/compare-urls) - Compare URLs by first normalizing them
  142. ---
  143. <div align="center">
  144. <b>
  145. <a href="https://tidelift.com/subscription/pkg/npm-normalize-url?utm_source=npm-normalize-url&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
  146. </b>
  147. <br>
  148. <sub>
  149. Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
  150. </sub>
  151. </div>