uri-utils.d.ts 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /**
  2. * A regular expression that is simply the character class of the characters
  3. * that may be used in a domain name, minus the '-' or '.'
  4. */
  5. export declare const domainNameCharRegex: RegExp;
  6. /**
  7. * The set of characters that will start a URL suffix (i.e. the path, query, and
  8. * hash part of the URL)
  9. */
  10. export declare const urlSuffixStartCharsRe: RegExp;
  11. /**
  12. * The set of characters that are allowed in the URL suffix (i.e. the path,
  13. * query, and hash part of the URL) which may also form the ending character of
  14. * the URL.
  15. *
  16. * The {@link #urlSuffixNotAllowedAsLastCharRe} are additional allowed URL
  17. * suffix characters, but (generally) should not be the last character of a URL.
  18. */
  19. export declare const urlSuffixAllowedSpecialCharsRe: RegExp;
  20. /**
  21. * URL suffix characters (i.e. path, query, and has part of the URL) that are
  22. * not allowed as the *last character* in the URL suffix as they would normally
  23. * form the end of a sentence.
  24. *
  25. * The {@link #urlSuffixAllowedSpecialCharsRe} contains additional allowed URL
  26. * suffix characters which are allowed as the last character.
  27. */
  28. export declare const urlSuffixNotAllowedAsLastCharRe: RegExp;
  29. /**
  30. * Regular expression to match an http:// or https:// scheme.
  31. */
  32. export declare const httpSchemeRe: RegExp;
  33. /**
  34. * Regular expression to match an http:// or https:// scheme as the prefix of
  35. * a string.
  36. */
  37. export declare const httpSchemePrefixRe: RegExp;
  38. export declare const urlSuffixedCharsNotAllowedAtEndRe: RegExp;
  39. /**
  40. * A regular expression used to determine the schemes we should not autolink
  41. */
  42. export declare const invalidSchemeRe: RegExp;
  43. export declare const schemeUrlRe: RegExp;
  44. export declare const tldUrlHostRe: RegExp;
  45. /**
  46. * Determines if the given character may start a scheme (ex: 'http').
  47. */
  48. export declare function isSchemeStartChar(char: string): boolean;
  49. /**
  50. * Determines if the given character is a valid character in a scheme (such as
  51. * 'http' or 'ssh+git'), but only after the start char (which is handled by
  52. * {@link isSchemeStartChar}.
  53. */
  54. export declare function isSchemeChar(char: string): boolean;
  55. /**
  56. * Determines if the character can begin a domain label, which must be an
  57. * alphanumeric character and not an underscore or dash.
  58. *
  59. * A domain label is a segment of a hostname such as subdomain.google.com.
  60. */
  61. export declare function isDomainLabelStartChar(char: string): boolean;
  62. /**
  63. * Determines if the character is part of a domain label (but not a domain label
  64. * start character).
  65. *
  66. * A domain label is a segment of a hostname such as subdomain.google.com.
  67. */
  68. export declare function isDomainLabelChar(char: string): boolean;
  69. /**
  70. * Determines if the character is a path character ("pchar") as defined by
  71. * https://tools.ietf.org/html/rfc3986#appendix-A
  72. *
  73. * pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
  74. *
  75. * unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
  76. * pct-encoded = "%" HEXDIG HEXDIG
  77. * sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
  78. * / "*" / "+" / "," / ";" / "="
  79. *
  80. * Note that this implementation doesn't follow the spec exactly, but rather
  81. * follows URL path characters found out in the wild (spec might be out of date?)
  82. */
  83. export declare function isPathChar(char: string): boolean;
  84. /**
  85. * Determines if the character given may begin the "URL Suffix" section of a
  86. * URI (i.e. the path, query, or hash section). These are the '/', '?' and '#'
  87. * characters.
  88. *
  89. * See https://tools.ietf.org/html/rfc3986#appendix-A
  90. */
  91. export declare function isUrlSuffixStartChar(char: string): boolean;
  92. /**
  93. * Determines if the TLD read in the host is a known TLD (Top-Level Domain).
  94. *
  95. * Example: 'com' would be a known TLD (for a host of 'google.com'), but
  96. * 'local' would not (for a domain name of 'my-computer.local').
  97. */
  98. export declare function isKnownTld(tld: string): boolean;
  99. /**
  100. * Determines if the given `url` is a valid scheme-prefixed URL.
  101. */
  102. export declare function isValidSchemeUrl(url: string): boolean;
  103. /**
  104. * Determines if the given `url` is a match with a valid TLD.
  105. */
  106. export declare function isValidTldMatch(url: string): boolean;
  107. /**
  108. * Determines if the given URL is a valid IPv4-prefixed URL.
  109. */
  110. export declare function isValidIpV4Address(url: string): boolean;