Skip to content

[WebProfilerBundle + AssetMapper] WebDebugToolbar throws exception and blocks code execution when URL object is used as EventSource's url param #62729

@RSKDeadBoi

Description

@RSKDeadBoi

Symfony version(s) affected

7.4.0 | 8.0

Description

Tested on Firefox For Developers 147.0b1 it that matters

WebDebugToolbar's JS code throws this Error when URL object is used to initialize EventSource

Uncaught TypeError: url.match is not a function

JS console points at column 16247 of WebDebugToolbar's JS code:

if (!url.match(new RegExp("^\/((index|app(_[\\w]+)?)\\.php\/)?_wdt"))) {
    ....
}

How to reproduce

src/Controller/ExampleController.php

extends AbstractController

#[Route(methods: 'GET', path: '/example')]
public function example(): Response {
    return $this->render('example.html.twig');
}

templates/example.html.twig

{% extends 'base.html.twig' %}
{% block importmap %}
    {{ importmap('example') }}
{% endblock %}

importmap.php

return [
    'example' => [
        'path' => 'assets/example.js',
        'entrypoint' => true
    ]
];

assets/example.js

let ES = new EventSource(new URL('https://example.com'));

Possible Solution

Handle 'url' variable being of URL type here

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions