From 744c9381ddd2044a73a53dedfa88cdce1c276475 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Papp?= Date: Wed, 27 Aug 2025 21:05:43 +0200 Subject: [PATCH] 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. --- extension_candidate_pair_id.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/extension_candidate_pair_id.go b/extension_candidate_pair_id.go index 306205e..0f156dc 100644 --- a/extension_candidate_pair_id.go +++ b/extension_candidate_pair_id.go @@ -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), } }