pico-engine
pico-engine copied to clipboard
Handling of special characters in channel tags complicates use of RID as a channel tag
When creating a channel (ctx:newChannel
(called by wrangler:createChannel
)) one of the parameters is an array of strings used as tags. Each tag is sanitized, to replace runs of special characters with a dash (the precise cleaning in code is here).
However, the same cleaning is not done in wrangler:channels
which returns channels with given tags.
A ruleset identifier (RID) can contain periods, so if a RID is used as one of the tags, that tag will not be equal to the RID!
Workaround is to do the necessary sanitation in KRL, as in this example:
ridAsTag = meta:rid.replace(re#[.]#g,"-")
and use ridAsTag
both in creating and in querying channels. Example in context here.
The precise cleaning to be done in KRL depends on the ruleset. In this case, the RID contains periods. RIDs that don't contain periods may not need this special treatment.
What to do about this?
- We could just document this and leave the code alone.
- We could modify
wrangler:channels
to do the equivalent cleaning in KRL. - We could expose the pico-framework
cleanChannelTags
in thectx
library and use it in Wrangler.
Also need to ensure that the tags are lowercase characters only, and RIDs allow for uppercase characters. so a more complete sanitation would be
ridAsTag = meta:rid.replace(re#[.]#g,"-").lc()