mirror of
https://github.com/netbirdio/ice.git
synced 2026-05-22 17:10:58 -07:00
Add prefix handling for candidate ID in extensions
Ensure candidate IDs are consistently prefixed with "candidate:" when retrieved and remove the prefix when creating a new extension. This improves standardization and avoids potential mismatches in formatting.
This commit is contained in:
@@ -1,14 +1,21 @@
|
||||
package ice
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
// used in RDP for candidate ID extension
|
||||
extensionKeyCandidateID = "cid"
|
||||
|
||||
candidateIDPrefix = "candidate:"
|
||||
)
|
||||
|
||||
func candidateIDFromExtensions(extensions []CandidateExtension) string {
|
||||
for _, ext := range extensions {
|
||||
if ext.Key == extensionKeyCandidateID {
|
||||
return ext.Value
|
||||
return fmt.Sprintf("candidate:%s", ext.Value)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +25,6 @@ func candidateIDFromExtensions(extensions []CandidateExtension) string {
|
||||
func newCandidateIDExtension(candidateID string) CandidateExtension {
|
||||
return CandidateExtension{
|
||||
Key: extensionKeyCandidateID,
|
||||
Value: candidateID,
|
||||
Value: strings.TrimPrefix(candidateID, candidateIDPrefix),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user