ContextAwareUrlTransformer.TryTransformUrl Method

Namespace
Kampute.DocToolkit.Routing
Assembly
  • Kampute.DocToolkit.dll

Definition

Attempts to transform a URL string into an absolute or document-relative URL.
public virtual bool TryTransformUrl(string urlString, [NotNullWhen(true)] out Uri transformedUrl)

Parameters

urlString string
The URL string to transform.
transformedUrl Uri
When this method returns, contains the transformed URL if the method returns true; otherwise, null. This parameter is passed uninitialized.

Returns

bool
true if the URL was transformed; otherwise, false.

Remarks

This method enables context-aware URL resolution across documentation components, ensuring that links work correctly regardless of where they appear within the documentation hierarchy.
  • Topic references are resolved to their corresponding URLs.
  • File references in topics are resolved to either absolute or document-relative URLs.
  • URLs relative to the root of the documentation site are resolved to either absolute or document-relative URLs.
The method will not transform the provided URL when it matches any of the following:
  • Empty or consists only of white-space.
  • A query or fragment-only URL (for example, "#section" or "?q=1").
  • An absolute or rooted URL (for example, starting with a scheme like "http:" or a leading "/").
  • Neither a known topic, a topic-relative file reference, nor a site-root-relative URL.