Skip to content

Commit 364eba0

Browse files
committed
Add missing window.origin
1 parent 8414c37 commit 364eba0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

mercure.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ as patterns:
210210
.. code-block:: javascript
211211
212212
// URL is a built-in JavaScript class to manipulate URLs
213-
const url = new URL('/.well-known/mercure');
213+
const url = new URL('/.well-known/mercure', window.origin);
214214
url.searchParams.append('topic', 'http://example.com/books/1');
215215
// Subscribe to updates of several Book resources
216216
url.searchParams.append('topic', 'http://example.com/books/2');
@@ -286,7 +286,7 @@ and to subscribe to it:
286286
const hubUrl = response.headers.get('Link').match(/<([^>]+)>;\s+rel=(?:mercure|"[^"]*mercure[^"]*")/)[1];
287287
288288
// Append the topic(s) to subscribe as query parameter
289-
const hub = new URL(hubUrl);
289+
const hub = new URL(hubUrl, window.origin);
290290
hub.searchParams.append('topic', 'http://example.com/books/{id}');
291291
292292
// Subscribe to updates

0 commit comments

Comments
 (0)