Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

index.d.ts 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. declare namespace normalizeUrl {
  2. interface Options {
  3. /**
  4. @default 'http:'
  5. */
  6. readonly defaultProtocol?: string;
  7. /**
  8. Prepends `defaultProtocol` to the URL if it's protocol-relative.
  9. @default true
  10. @example
  11. ```
  12. normalizeUrl('//sindresorhus.com:80/');
  13. //=> 'http://sindresorhus.com'
  14. normalizeUrl('//sindresorhus.com:80/', {normalizeProtocol: false});
  15. //=> '//sindresorhus.com'
  16. ```
  17. */
  18. readonly normalizeProtocol?: boolean;
  19. /**
  20. Normalizes `https:` URLs to `http:`.
  21. @default false
  22. @example
  23. ```
  24. normalizeUrl('https://sindresorhus.com:80/');
  25. //=> 'https://sindresorhus.com'
  26. normalizeUrl('https://sindresorhus.com:80/', {forceHttp: true});
  27. //=> 'http://sindresorhus.com'
  28. ```
  29. */
  30. readonly forceHttp?: boolean;
  31. /**
  32. Normalizes `http:` URLs to `https:`.
  33. This option can't be used with the `forceHttp` option at the same time.
  34. @default false
  35. @example
  36. ```
  37. normalizeUrl('https://sindresorhus.com:80/');
  38. //=> 'https://sindresorhus.com'
  39. normalizeUrl('http://sindresorhus.com:80/', {forceHttps: true});
  40. //=> 'https://sindresorhus.com'
  41. ```
  42. */
  43. readonly forceHttps?: boolean;
  44. /**
  45. Strip the [authentication](https://en.wikipedia.org/wiki/Basic_access_authentication) part of a URL.
  46. @default true
  47. @example
  48. ```
  49. normalizeUrl('user:password@sindresorhus.com');
  50. //=> 'https://sindresorhus.com'
  51. normalizeUrl('user:password@sindresorhus.com', {stripAuthentication: false});
  52. //=> 'https://user:password@sindresorhus.com'
  53. ```
  54. */
  55. readonly stripAuthentication?: boolean;
  56. /**
  57. Removes hash from the URL.
  58. @default false
  59. @example
  60. ```
  61. normalizeUrl('sindresorhus.com/about.html#contact');
  62. //=> 'http://sindresorhus.com/about.html#contact'
  63. normalizeUrl('sindresorhus.com/about.html#contact', {stripHash: true});
  64. //=> 'http://sindresorhus.com/about.html'
  65. ```
  66. */
  67. readonly stripHash?: boolean;
  68. /**
  69. Removes HTTP(S) protocol from an URL `http://sindresorhus.com` → `sindresorhus.com`.
  70. @default false
  71. @example
  72. ```
  73. normalizeUrl('https://sindresorhus.com');
  74. //=> 'https://sindresorhus.com'
  75. normalizeUrl('sindresorhus.com', {stripProtocol: true});
  76. //=> 'sindresorhus.com'
  77. ```
  78. */
  79. readonly stripProtocol?: boolean;
  80. /**
  81. Removes `www.` from the URL.
  82. @default true
  83. @example
  84. ```
  85. normalizeUrl('http://www.sindresorhus.com');
  86. //=> 'http://sindresorhus.com'
  87. normalizeUrl('http://www.sindresorhus.com', {stripWWW: false});
  88. //=> 'http://www.sindresorhus.com'
  89. ```
  90. */
  91. readonly stripWWW?: boolean;
  92. /**
  93. Removes query parameters that matches any of the provided strings or regexes.
  94. @default [/^utm_\w+/i]
  95. @example
  96. ```
  97. normalizeUrl('www.sindresorhus.com?foo=bar&ref=test_ref', {
  98. removeQueryParameters: ['ref']
  99. });
  100. //=> 'http://sindresorhus.com/?foo=bar'
  101. ```
  102. */
  103. readonly removeQueryParameters?: ReadonlyArray<RegExp | string>;
  104. /**
  105. Removes trailing slash.
  106. __Note__: Trailing slash is always removed if the URL doesn't have a pathname.
  107. @default true
  108. @example
  109. ```
  110. normalizeUrl('http://sindresorhus.com/redirect/');
  111. //=> 'http://sindresorhus.com/redirect'
  112. normalizeUrl('http://sindresorhus.com/redirect/', {removeTrailingSlash: false});
  113. //=> 'http://sindresorhus.com/redirect/'
  114. normalizeUrl('http://sindresorhus.com/', {removeTrailingSlash: false});
  115. //=> 'http://sindresorhus.com'
  116. ```
  117. */
  118. readonly removeTrailingSlash?: boolean;
  119. /**
  120. Removes the default directory index file from path that matches any of the provided strings or regexes.
  121. When `true`, the regex `/^index\.[a-z]+$/` is used.
  122. @default false
  123. @example
  124. ```
  125. normalizeUrl('www.sindresorhus.com/foo/default.php', {
  126. removeDirectoryIndex: [/^default\.[a-z]+$/]
  127. });
  128. //=> 'http://sindresorhus.com/foo'
  129. ```
  130. */
  131. readonly removeDirectoryIndex?: ReadonlyArray<RegExp | string>;
  132. /**
  133. Sorts the query parameters alphabetically by key.
  134. @default true
  135. @example
  136. ```
  137. normalizeUrl('www.sindresorhus.com?b=two&a=one&c=three', {
  138. sortQueryParameters: false
  139. });
  140. //=> 'http://sindresorhus.com/?b=two&a=one&c=three'
  141. ```
  142. */
  143. readonly sortQueryParameters?: boolean;
  144. }
  145. }
  146. declare const normalizeUrl: {
  147. /**
  148. [Normalize](https://en.wikipedia.org/wiki/URL_normalization) a URL.
  149. @param url - URL to normalize, including [data URL](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs).
  150. @example
  151. ```
  152. import normalizeUrl = require('normalize-url');
  153. normalizeUrl('sindresorhus.com');
  154. //=> 'http://sindresorhus.com'
  155. normalizeUrl('HTTP://xn--xample-hva.com:80/?b=bar&a=foo');
  156. //=> 'http://êxample.com/?a=foo&b=bar'
  157. ```
  158. */
  159. (url: string, options?: normalizeUrl.Options): string;
  160. // TODO: Remove this for the next major release, refactor the whole definition to:
  161. // declare function normalizeUrl(url: string, options?: normalizeUrl.Options): string;
  162. // export = normalizeUrl;
  163. default: typeof normalizeUrl;
  164. };
  165. export = normalizeUrl;