How to use the @hint/utils-network.isHTTP function in @hint/utils-network

To help you get started, we’ve selected a few @hint/utils-network examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github webhintio / hint / packages / parser-manifest / src / parser.ts View on Github external
private async fetchManifest(elementFound: ElementFound) {
        const { element, resource } = elementFound;

        /*
         * Check if the target is a local file, and if it is,
         * don't try to fetch the web app manifest file as it's
         * `href` value will most probably not map to anything
         * on disk and the request will fail.
         *
         * TODO: Remove this once things work as expected.
         */

        if (!isHTTP(resource) && !isHTTPS(resource)) {
            return;
        }

        // Check if the `link` tag is for the web app manifest.

        if (normalizeString(element.getAttribute('rel')) !== 'manifest') {
            return;
        }

        // If so, check if a non-empty `href` was specified.

        const hrefValue: string | null = normalizeString(element.getAttribute('href'));

        if (!hrefValue) {
            return;
        }
github webhintio / hint / packages / hint-http-compression / src / hint.ts View on Github external
resource,
                    getMessage('couldNotBeFetchedBrotli', context.language),
                    { element, severity: Severity.error }
                );

                return;
            }

            const { contentEncodingHeaderValue, rawResponse, response } = networkData;
            const compressedWithBrotli = await isCompressedWithBrotli(rawResponse);

            // - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

            // Check if compressed with Brotli over HTTP.

            if (isHTTP(resource)) {
                if (compressedWithBrotli) {
                    context.report(
                        resource,
                        getMessage('noCompressedBrotliOverHTTP', context.language),
                        { element, severity: Severity.warning }
                    );
                }

                return;
            }

            // - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

            // Check compressed vs. uncompressed sizes.

            /*