Skip to content
This repository was archived by the owner on Apr 8, 2020. It is now read-only.
This repository was archived by the owner on Apr 8, 2020. It is now read-only.

Content security policy #345

Description

@MrCrimp

The following files where reported from content security policy checking
domain-task/fetch.js

Inline eval() and functions() are not compliant with content security policy
var isBrowser = (new Function('try { return this === window; } catch (e) { return false; }'))();

This is how I'd do the same test

export const isNode = (typeof process === 'object' && Object.prototype.toString.call(process) === '[object process]');
export const isBrowser = !isNode && Object.prototype.toString.call(window) === '[object Window]';

Activity

  1. SteveSandersonMS commented on Nov 7, 2016

    @SteveSandersonMS
    Member

    Thanks for the suggestion. In the end I used the following test as it's quite succinct and explicit:

    const isNode = typeof process === 'object' && process.versions && !!process.versions.node;
    

    If you think there's anything inadequate about that test, please let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions