< Summary - Kestrun — Combined Coverage

Information
Class: Public.Middleware.Cors.Set-KrCorsOrigin
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Middleware/Cors/Set-KrCorsOrigin.ps1
Tag: Kestrun/Kestrun@0d738bf294e6281b936d031e1979d928007495ff
Line coverage
0%
Covered lines: 0
Uncovered lines: 5
Coverable lines: 5
Total lines: 49
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 12/14/2025 - 20:04:52 Line coverage: 0% (0/5) Total lines: 49 Tag: Kestrun/Kestrun@a05ac8de57c6207e227b92ba360e9d58869ac80a

Metrics

File(s)

/home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Middleware/Cors/Set-KrCorsOrigin.ps1

#LineLine coverage
 1<#
 2.SYNOPSIS
 3    Sets the CORS origin for a given CorsPolicyBuilder object.
 4.DESCRIPTION
 5    This function sets the CORS origin for a given CorsPolicyBuilder object. It supports setting the origin to any value
 6.PARAMETER Builder
 7    The CorsPolicyBuilder object to set the CORS origin for.
 8.PARAMETER Any
 9    If specified, sets the CORS origin to any value.
 10.PARAMETER Origins
 11    The specific set of origins to allow.
 12.PARAMETER AllowWildcardSubdomains
 13    If specified, allows wildcard subdomains for the CORS origin.
 14.EXAMPLE
 15    New-KrCorsPolicyBuilder | Set-KrCorsOrigin -Builder $corsPolicyBuilder -Any
 16    Sets the CORS origin to any value.
 17.EXAMPLE
 18    New-KrCorsPolicyBuilder | Set-KrCorsOrigin -Builder $corsPolicyBuilder -Origins @('http://example.com', 'https://exa
 19    Sets the CORS origin to a specific set of origins.
 20#>
 21function Set-KrCorsOrigin {
 22    [KestrunRuntimeApi('Definition')]
 23    [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '')]
 24    [CmdletBinding(DefaultParameterSetName = 'With')]
 25    [OutputType([Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder])]
 26    param(
 27        [Parameter(Mandatory, ValueFromPipeline)]
 28        [Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder]$Builder,
 29
 30        [Parameter(Mandatory, ParameterSetName = 'Any')]
 31        [switch]$Any,
 32
 33        [Parameter(Mandatory, ParameterSetName = 'With')]
 34        [string[]]$Origins,
 35
 36        [Parameter(ParameterSetName = 'With')]
 37        [switch]$AllowWildcardSubdomains
 38    )
 39    process {
 040        if ($Any) { $Builder.AllowAnyOrigin() | Out-Null }
 041        else { $Builder.WithOrigins($Origins) | Out-Null }
 42
 043        if ($AllowWildcardSubdomains) {
 044            $Builder.SetIsOriginAllowedToAllowWildcardSubdomains() | Out-Null
 45        }
 46
 047        $Builder
 48    }
 49}

Methods/Properties

Set-KrCorsOrigin()