toSourceString method
Returns the CSP string.
If the instance was constructed by parse or tryParse, the method returns the original parsed string.
Otherwise the method constructs a new string.
Implementation
String toSourceString() {
var source = _source;
if (source == null) {
final directiveNames = directivesMap.keys.toList(growable: false)..sort();
final sb = StringBuffer();
var semicolon = false;
final sortedDirectiveNames = directiveNames.toList(growable: false)
..sort();
for (var directiveName in sortedDirectiveNames) {
if (semicolon) {
sb.write('; ');
}
semicolon = true;
sb.write(directiveName);
final arguments = directivesMap[directiveName]!;
for (var argument in arguments) {
sb.write(' ');
sb.write(argument);
}
}
source = sb.toString();
_source = source;
}
return source;
}