diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 00000000000..d5d401c5189 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,31 @@ +# Use the latest 2.1 version of CircleCI pipeline process engine. +# See: https://circleci.com/docs/configuration-reference +version: 2.1 + +# Define a job to be invoked later in a workflow. +# See: https://circleci.com/docs/jobs-steps/#jobs-overview & https://circleci.com/docs/configuration-reference/#jobs +jobs: + say-hello: + # Specify the execution environment. You can specify an image from Docker Hub or use one of our convenience images from CircleCI's Developer Hub. + # See: https://circleci.com/docs/executor-intro/ & https://circleci.com/docs/configuration-reference/#executor-job + docker: + # Specify the version you desire here + # See: https://circleci.com/developer/images/image/cimg/base + - image: cimg/base:current + + # Add steps to the job + # See: https://circleci.com/docs/jobs-steps/#steps-overview & https://circleci.com/docs/configuration-reference/#steps + steps: + # Checkout the code as the first step. + - checkout + - run: + name: "Say hello" + command: "echo Hello, World!" + +# Orchestrate jobs using workflows +# See: https://circleci.com/docs/workflows/ & https://circleci.com/docs/configuration-reference/#workflows +workflows: + say-hello-workflow: # This is the name of the workflow, feel free to change it to better match your workflow. + # Inside the workflow, you define the jobs you want to run. + jobs: + - say-hello diff --git a/packages/sessions/src/challenge-solvers/turnstileSolver.integration.test.ts b/packages/sessions/src/challenge-solvers/turnstileSolver.integration.test.ts index cc74851befe..26bdfe10c8f 100644 --- a/packages/sessions/src/challenge-solvers/turnstileSolver.integration.test.ts +++ b/packages/sessions/src/challenge-solvers/turnstileSolver.integration.test.ts @@ -39,7 +39,16 @@ beforeAll(() => { }) vi.spyOn(document.head, 'appendChild').mockImplementation((node) => { - if (node instanceof HTMLScriptElement && node.src.includes('challenges.cloudflare.com')) { + let isTurnstileScript = false + if (node instanceof HTMLScriptElement && node.src) { + try { + const url = new URL(node.src, window.location.origin) + isTurnstileScript = url.hostname === 'challenges.cloudflare.com' + } catch { + isTurnstileScript = false + } + } + if (isTurnstileScript) { // Simulate script load immediately setTimeout(() => { // Set up the mock turnstile API @@ -262,12 +271,19 @@ describe('Turnstile Solver Integration Tests', () => { it('handles script loading failures', async () => { // Mock script loading failure vi.spyOn(document.head, 'appendChild').mockImplementationOnce((node) => { - if (node instanceof HTMLScriptElement && node.src.includes('challenges.cloudflare.com')) { - setTimeout(() => { - if (node.onerror) { - node.onerror({} as Event) + if (node instanceof HTMLScriptElement && node.src) { + try { + const url = new URL(node.src, window.location.origin) + if (url.hostname === 'challenges.cloudflare.com') { + setTimeout(() => { + if (node.onerror) { + node.onerror({} as Event) + } + }, 0) } - }, 0) + } catch { + // If the URL is invalid, do not treat it as the Turnstile script + } } return node })