Types/OpenPackage.Part/get_IsEponym.ps1

<#
.SYNOPSIS
    Determines if a part is an eponym
.DESCRIPTION
    Eponyms are files whose name matches their directory.

    For example:

    `/foo/foo.ps1` is an eponym
    `/foo/foo.md` is an eponym
    `/foo/bar.ps1` is not an eponym

    If a package has an an identifier,
    any files whose name matches this identifier will be considered an eponym.
.NOTES
    Multiple eponyms may exist for a given path.

    Anything before the first period `.` will be considered the name of the file.
#>

param()
$part = $this

$partSegments = @($part.Uri -split '/+' -ne '')

if ($partSegments.Count -eq 1 -and $this.Package.Identifier) {
    if ($partSegments[0] -replace '\..+$' -eq $this.Package.Identifier) {
        return $true
    }
}

if ($partSegments.Count -ge 2) {
    if ($partSegments[-2] -eq 
        ($partSegments[-1] -replace '\..+$')
    ) {
        return $true
    }
}

return $false