Fix map marker photos: escapeCssUrl no longer encodes the letter "s"

The character class /['"()\s<>]/ matched a backslash and the letter "s"
instead of whitespace, so every "s" in a marker image URL became %73
(https:// -> http%73://). The colored circles still rendered, but the
background-image URL was broken. Use \\s (backslash + whitespace).

Add tests: escapeCssUrl keeps a presigned URL intact and still encodes
backslash/whitespace; MapView puts the original imageUrl into the marker
template.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
SlimusMinus
2026-10-21 22:51:36 +03:00
parent f25d034cad
commit bfc9a1bd1d
3 changed files with 35 additions and 1 deletions

View File

@@ -237,3 +237,24 @@ test("даже если границы так и не пришли, карта
{ timeout: 8000 }
);
});
test("в шаблон маркера попадает рабочий URL картинки объявления", async () => {
// Регрессия: escapeCssUrl кодировал каждую букву s, и https:// превращался
// в http%73:// — кружки рисовались, а фото внутри них пропадали.
const imageUrl = "https://s3.example.com/refound/posts/a.jpg?X-Amz-Signature=abc";
fetchMock.mockResolvedValue({
ok: true,
json: async () => [
{ id: 1, latitude: 55.75, longitude: 37.61, type: "FOUND", title: "Ключи", imageUrl },
],
});
const ymaps = installFakeYmaps();
render(<MapView onBack={() => {}} />);
ymaps.publishBounds();
await waitFor(() => expect(window.ymaps.Placemark).toHaveBeenCalled());
const template = window.ymaps.templateLayoutFactory.createClass.mock.calls[0][0];
expect(template).toContain(`background-image:url('${imageUrl}')`);
});