diff --git a/core/modules/system/src/Controller/AssetControllerBase.php b/core/modules/system/src/Controller/AssetControllerBase.php
index 0e25e72ab6fd428ab87b21686544415d11d5deff..197af589cb6d454a5ec4fe701e6870f4a42b5a61 100644
--- a/core/modules/system/src/Controller/AssetControllerBase.php
+++ b/core/modules/system/src/Controller/AssetControllerBase.php
@@ -162,10 +162,11 @@ public function deliver(Request $request, string $file_name) {
     $attached_assets = new AttachedAssets();
     $include_libraries = explode(',', UrlHelper::uncompressQueryParameter($request->query->get('include')));
 
+    // Check that library names are in the correct format.
     $validate = function ($libraries_to_check) {
       foreach ($libraries_to_check as $library) {
-        if (substr_count($library, '/') !== 1) {
-          throw new BadRequestHttpException('The libraries to include are encoded incorrectly.');
+        if (substr_count($library, '/') === 0) {
+          throw new BadRequestHttpException(sprintf('The "%s" library name must include at least one slash.', $library));
         }
       }
     };