getAllowedSources method

List<String> getAllowedSources({
  1. required String type,
})

Returns directives for the type ('connect', 'img', etc.).

Example

final allowesSources = csp.getAllowedSources(type: 'img');

Implementation

List<String> getAllowedSources({required String type}) {
  // Prevent developers from using the API incorrectly.
  if (type.endsWith('-src')) {
    throw ArgumentError.value(type, 'type', 'Must not end with "-src"');
  }
  return directivesMap['$type-src'] ??
      directivesMap['default-src'] ??
      const <String>[];
}