Add NameToket.toStringUnescaped

This commit is contained in:
Alexander Nozik 2022-06-24 18:44:36 +03:00
parent 0b68c1edae
commit 9cceb44a90
No known key found for this signature in database
GPG Key ID: F7FCF2DD25C71357

View File

@ -27,6 +27,16 @@ public data class NameToken(val body: String, val index: String? = null) {
body.escape()
}
/**
* Return unescaped version of the [NameToken]. Should be used only for output because it is not possible to correctly
* parse it back.
*/
public fun toStringUnescaped(): String = if (hasIndex()) {
"${body}[$index]"
} else {
body
}
public companion object {
/**