src/packages/EmbedIO/Utilities/UrlPath.cs
/// <summary>
/// Strips a base URL path fom a URL path, obtaining a relative path,
/// assuming both paths are valid and normalized.
/// </summary>
/// <param name="path">The URL path.</param>
/// <param name="basePath">The base URL path.</param>
/// <returns>The relative path, or <see langword="null"/> if <paramref name="path"/>
/// is not prefixed by <paramref name="basePath"/>.</returns>
/// <remarks>
/// <para>Unless both <paramref name="path"/> and <paramref name="basePath"/> are valid,
/// normalized URL paths, the behavior of this method is unspecified. You should call this method
/// only after calling either <see cref="Normalize"/> or <see cref="Validate.UrlPath"/>
/// to check and normalize both parameters.</para>
/// <para>If you are not sure about the validity and/or normalization of parameters,
/// call <see cref="StripPrefix"/> instead of this method.</para>
/// <para>The returned relative path is NOT prefixed by a slash (<c>/</c>) character.</para>
/// <para>If <paramref name="path"/> and <paramref name="basePath"/> are equivalent,
/// for example if both are <c>"/"</c>, or if <paramref name="path"/> is <c>"/download"</c>
/// and <paramref name="basePath"/> is <c>"/download/"</c>, this method returns an empty string.</para>
/// </remarks>
/// <seealso cref="StripPrefix"/>
/// <seealso cref="Normalize"/>
/// <seealso cref="HasPrefix"/>
/// <seealso cref="Validate.UrlPath"/>
Strips a base URL path fom a URL path, obtaining a relative path,
assuming both paths are valid and normalized.
Strips a base URL path fom a URL path obtaining a relative path assuming both paths are valid and normalized .
public static string? UnsafeStripPrefix(string path, string basePath)
        {
            if (!UnsafeHasPrefix(path, basePath))
                return null;
            return path.Length < basePath.Length
                ? string.Empty
                : path.Substring(basePath.Length);
        }
public static string ? UnsafeStripPrefix ( string path , string basePath ) { if ( ! UnsafeHasPrefix ( path , basePath ) ) return null ; return path . Length < basePath . Length ? string . Empty : path . Substring ( basePath . Length ) ; }
Strips a base URL path fom a URL path, obtaining a relative path,
assuming both paths are valid and normalized.
Strips a base URL path fom a URL path obtaining a relative path assuming both paths are valid and normalized .
// The only case where UnsafeHasPrefix returns true for a urlPath shorter than baseUrlPath // is urlPath == (baseUrlPath minus the final slash).
The relative path, or  if
is not prefixed by .
The relative path or if is not prefixed by .
path
string
The URL path.
The URL path .
basePath
string
The base URL path.
The base URL path .
remarks
Unless both  and  are valid,
normalized URL paths, the behavior of this method is unspecified. You should call this method
only after calling either  or
to check and normalize both parameters.If you are not sure about the validity and/or normalization of parameters,
call  instead of this method.The returned relative path is NOT prefixed by a slash (/If  and  are equivalent,
for example if both are "/" is "/download" is "/download/"
Unless both and are valid normalized URL paths the behavior of this method is unspecified . You should call this method only after calling either or to check and normalize both parameters . If you are not sure about the validity and / or normalization of parameters call instead of this method . The returned relative path is NOT prefixed by a slash ( / If and are equivalent for example if both are " / " is " / download " is " / download / "
seealso
None
seealso
None
seealso
None
seealso
None