Skip to content

Commit db26132

Browse files
authoredMay 28, 2020
fix: handle jwt messages correctly in daf-url in browser environments
I was sending through a message with a JWT in the raw and my agent running in the browser has in the MessageHandler chain `daf-url` active. I ran into errors because `const parsed = parse(message.raw, true)` returned an URL object with the URL of the page. The URL came out as http://localhost:3000/jwthere. Which of course did not resolve to something dad could understand. After some digging, I found the following in the `url-parse` documentation > Note that when `url-parse` is used in a browser environment, it will default to using the browser's current window location as the base URL when parsing all inputs. To parse an input independently of the browser's current URL (e.g. for functionality parity with the library in a Node environment), pass an empty location object as the second parameter. (https://github.com/unshiftio/url-parse/pull/65/files) This commit adds the {} parameter.
1 parent d82de54 commit db26132

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed
 

‎packages/daf-url/src/message-handler.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const debug = Debug('daf:url:message-handler')
66

77
export class UrlMessageHandler extends AbstractMessageHandler {
88
async handle(message: Message, agent: Agent): Promise<Message> {
9-
const parsed = parse(message.raw, true)
9+
const parsed = parse(message.raw, {}, true)
1010

1111
if (parsed && parsed.query && parsed.query.c_i) {
1212
debug('Detected standard URL')

0 commit comments

Comments
 (0)
Please sign in to comment.