frmDocumentResultList

This commit is contained in:
Jonathan Jenne
2019-09-30 14:16:37 +02:00
parent d78254fc9c
commit 9f270d93c9
14 changed files with 436 additions and 114 deletions

View File

@@ -1,4 +1,5 @@
''' <summary>
Imports System.Text
''' <summary>
''' Provides common utility functions that do not require a specific context.
''' </summary>
Public Class Utils
@@ -35,4 +36,31 @@ Public Class Utils
Return value
End If
End Function
''' <summary>
''' Creates a "slug" from text that can be used as part of a valid URL.
''' Invalid characters are converted to hyphens. Punctuation that Is
''' perfect valid in a URL Is also converted to hyphens to keep the
''' result mostly text. Steps are taken to prevent leading, trailing,
''' And consecutive hyphens.
''' </summary>
''' <param name="s">The string to convert</param>
Public Shared Function ConvertTextToSlug(ByVal s As String) As String
Dim oBuilder As StringBuilder = New StringBuilder()
Dim oWasHyphen As Boolean = True
For Each oChar As Char In s
If Char.IsLetterOrDigit(oChar) Then
oBuilder.Append(Char.ToLower(oChar))
oWasHyphen = False
ElseIf Char.IsWhiteSpace(oChar) AndAlso Not oWasHyphen Then
oBuilder.Append("-"c)
oWasHyphen = True
End If
Next
If oWasHyphen AndAlso oBuilder.Length > 0 Then oBuilder.Length -= 1
Return oBuilder.ToString()
End Function
End Class