How to use the hint/dist/src/lib/utils/misc/cut-string function in hint

To help you get started, we’ve selected a few hint 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 / utils-debugging-protocol-common / src / debugging-protocol-connector.ts View on Github external
private async onRequestWillBeSent(params: Crdp.Network.RequestWillBeSentEvent) {
        const requestUrl: string = params.request.url;

        debug(`About to start fetching ${cutString(requestUrl)} (${params.requestId})`);

        this._requests.set(params.requestId, params);

        if (!this._headers) {
            // TODO: do some clean up, we probably don't want all the headers as the "defaults".
            this._headers = params.request.headers;
        }

        if (params.redirectResponse) {
            debug(`Redirect found for ${cutString(requestUrl)}`);

            if (requestUrl === params.redirectResponse.url) {
                logger.error(`Error redirecting: ${requestUrl} is an infinite loop`);

                return;
            }

            const hops = this._redirects.calculate(requestUrl);

            // We limit the number of redirects
            if (hops.length >= 10) {
                logger.error(`More than 10 redirects found for ${requestUrl}`);

                return;
            }
github webhintio / hint / packages / utils-debugging-protocol-common / src / debugging-protocol-connector.ts View on Github external
self._rawResponse = value;
                            }

                            return value;
                        });
                }
            };

            debug(`Content for ${cutString(cdpResponse.response.url)} downloaded`);

            return returnValue;
        } catch (e) {
            debug(`Body requested after connection closed for request ${cdpResponse.requestId}`);
            defaultBody.rawContent = Buffer.alloc(0);

            debug(`Content for ${cutString(cdpResponse.response.url)} downloaded`);

            return defaultBody;
        }
    }
github webhintio / hint / packages / utils-debugging-protocol-common / src / debugging-protocol-connector.ts View on Github external
.then((result) => {
                            const { response: { body: { rawResponse: rr } } } = result;

                            return rr();
                        })
                        .then((value) => {
                            if (self) {
                                self._rawResponse = value;
                            }

                            return value;
                        });
                }
            };

            debug(`Content for ${cutString(cdpResponse.response.url)} downloaded`);

            return returnValue;
        } catch (e) {
            debug(`Body requested after connection closed for request ${cdpResponse.requestId}`);
            defaultBody.rawContent = Buffer.alloc(0);

            debug(`Content for ${cutString(cdpResponse.response.url)} downloaded`);

            return defaultBody;
        }
    }