Iri.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. namespace Ganss.Xss;
  2. /// <summary>
  3. /// Represents an Internationalized Resource Identifier.
  4. /// </summary>
  5. /// <remarks>
  6. /// Initializes a new instance of the <see cref="Iri"/> class.
  7. /// </remarks>
  8. /// <param name="value">The value.</param>
  9. /// <param name="scheme">The scheme.</param>
  10. public class Iri(string value, string? scheme = null)
  11. {
  12. /// <summary>
  13. /// Gets or sets the value of the IRI.
  14. /// </summary>
  15. /// <value>
  16. /// The value of the IRI.
  17. /// </value>
  18. public string Value { get; private set; } = value;
  19. /// <summary>
  20. /// Gets a value indicating whether the IRI is absolute.
  21. /// </summary>
  22. /// <value>
  23. /// <c>true</c> if the IRI is absolute; otherwise, <c>false</c>.
  24. /// </value>
  25. public bool IsAbsolute => !string.IsNullOrEmpty(Scheme);
  26. /// <summary>
  27. /// Gets or sets the scheme of the IRI, e.g. "https".
  28. /// </summary>
  29. /// <value>
  30. /// The scheme of the IRI.
  31. /// </value>
  32. public string? Scheme { get; private set; } = scheme;
  33. }