Skip to content

Commit

Permalink
fix(util-user-agent-browser): window can be undefined (#2214)
Browse files Browse the repository at this point in the history
In sandboxed environments (pure v8) `window` can be undefined. Should not fail.
Actually should always check for `globalThis` instead, but IE 11 is still alive....
  • Loading branch information
pkit authored Apr 8, 2021
1 parent 0745502 commit 98b65b9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/util-user-agent-browser/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const defaultUserAgent = ({
serviceId,
clientVersion,
}: DefaultUserAgentOptions): Provider<UserAgent> => async () => {
const parsedUA = window?.navigator?.userAgent ? bowser.parse(window.navigator.userAgent) : undefined;
const parsedUA = (typeof window !== 'undefined' && window?.navigator?.userAgent) ? bowser.parse(window.navigator.userAgent) : undefined;
const sections: UserAgent = [
// sdk-metadata
["aws-sdk-js", clientVersion],
Expand Down

0 comments on commit 98b65b9

Please sign in to comment.