diff --git a/airflow/www/static/js/dag/details/taskInstance/Logs/utils.test.tsx b/airflow/www/static/js/dag/details/taskInstance/Logs/utils.test.tsx index aa835985d752d..bcebb22ec9a05 100644 --- a/airflow/www/static/js/dag/details/taskInstance/Logs/utils.test.tsx +++ b/airflow/www/static/js/dag/details/taskInstance/Logs/utils.test.tsx @@ -38,6 +38,7 @@ const mockTaskLog = ` [2022-06-04 00:00:01,921] {dagbag.py:507} INFO - Filling up the DagBag from /files/dags/test_ui_grid.py [2022-06-04 00:00:01,964] {task_command.py:377} INFO - Running on host 5d28cfda3219 [2022-06-04 00:00:02,010] {taskinstance.py:1548} WARNING - Exporting env vars: AIRFLOW_CTX_DAG_OWNER=*** AIRFLOW_CTX_DAG_ID=test_ui_grid +[2024-07-01 00:00:02,010] {taskinstance.py:1548} INFO - Url parsing test => "https://apple.com", "https://google.com" `; describe("Test Logs Utils.", () => { @@ -64,7 +65,7 @@ describe("Test Logs Utils.", () => { test.each([ { logLevelFilters: [LogLevel.INFO], - expectedNumberOfLines: 11, + expectedNumberOfLines: 12, expectedNumberOfFileSources: 4, }, { @@ -111,7 +112,7 @@ describe("Test Logs Utils.", () => { "taskinstance.py", ]); const lines = parsedLogs!.split("\n"); - expect(lines).toHaveLength(7); + expect(lines).toHaveLength(8); lines.forEach((line) => expect(line).toContain("taskinstance.py")); }); @@ -131,7 +132,25 @@ describe("Test Logs Utils.", () => { "taskinstance.py", ]); const lines = parsedLogs!.split("\n"); - expect(lines).toHaveLength(7); + expect(lines).toHaveLength(8); lines.forEach((line) => expect(line).toMatch(/INFO|WARNING/)); }); + + test("parseLogs function with quoted urls", () => { + const { parsedLogs } = parseLogs( + mockTaskLog, + null, + [LogLevel.INFO, LogLevel.WARNING], + ["taskinstance.py"], + [] + ); + + const lines = parsedLogs!.split("\n"); + expect(lines[lines.length - 1]).toContain( + 'https://apple.com' + ); + expect(lines[lines.length - 1]).toContain( + 'https://google.com' + ); + }); }); diff --git a/airflow/www/static/js/dag/details/taskInstance/Logs/utils.ts b/airflow/www/static/js/dag/details/taskInstance/Logs/utils.ts index 0de5676916bbb..49e922a91d051 100644 --- a/airflow/www/static/js/dag/details/taskInstance/Logs/utils.ts +++ b/airflow/www/static/js/dag/details/taskInstance/Logs/utils.ts @@ -74,7 +74,7 @@ export const parseLogs = ( const ansiUp = new AnsiUp(); ansiUp.url_allowlist = {}; - const urlRegex = /((https?:\/\/|http:\/\/)[^\s]+)/g; + const urlRegex = /((https?:\/\/|http:\/\/)(?:(?!'|")[^\s])+)/g; // Detect log groups which can be collapsed // Either in Github like format '::group::' to '::endgroup::' // see https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#grouping-log-lines