' Collection of code snippets by Arne Vajhøj 
' (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
Imports System
Imports System.Text.RegularExpressions

Public Class Test
    Public Shared Function FirstPart(ByVal s As String) As String
        FirstPart = Regex.Matches(s, "(http://[^/]*/)")(0).Groups(1).Value
    End Function

    Public Shared Function SameSite(ByVal url1 As String, ByVal url2 As String) As Boolean
        SameSite = (FirstPart(url1) = FirstPart(url2))
    End Function

    Public Shared Sub Main(args() As String)
        Console.WriteLine(SameSite("http://www.aaa.dk/x.html", "http://www.aaa.dk/y.html"))
        Console.WriteLine(SameSite("http://www.aaa.dk/x.html", "http://www.bbb.dk/x.html"))
    End Sub
End Class
