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:
Zoltán Papp
2025-08-27 21:05:43 +02:00
parent a191e76b63
commit 744c9381dd
+9 -2
View File
@@ -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),
}
}