Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions src/__tests__/utils/job.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ import { describe, it, expect } from 'vitest';
import { isJobId, isValidUrl } from '../../utils/job';

describe('isJobId', () => {
it('should return true for valid UUID v4 format', () => {
it('should return true for valid UUID formats', () => {
// UUID v4
expect(isJobId('550e8400-e29b-41d4-a716-446655440000')).toBe(true);
expect(isJobId('123e4567-e89b-42d3-a456-426614174000')).toBe(true); // Fixed: version digit must be 4
expect(isJobId('123e4567-e89b-42d3-a456-426614174000')).toBe(true);
expect(isJobId('00000000-0000-4000-8000-000000000000')).toBe(true);
expect(isJobId('ffffffff-ffff-4fff-8fff-ffffffffffff')).toBe(true);
// UUID v7 (Firecrawl uses this)
expect(isJobId('019c0ed5-126b-7581-90f1-894a349a1e9d')).toBe(true);
});

it('should return false for invalid UUID formats', () => {
Expand All @@ -29,11 +32,6 @@ describe('isJobId', () => {
expect(isJobId('550E8400-E29B-41D4-A716-446655440000')).toBe(true);
expect(isJobId('550e8400-E29b-41d4-A716-446655440000')).toBe(true);
});

it('should return false for UUID v1 format', () => {
// UUID v1 has different version number (1 instead of 4)
expect(isJobId('550e8400-e29b-11d4-a716-446655440000')).toBe(false);
});
});

describe('isValidUrl', () => {
Expand Down
5 changes: 2 additions & 3 deletions src/utils/job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@

/**
* Check if a string looks like a UUID/job ID
* Firecrawl job IDs are UUIDs (e.g., "550e8400-e29b-41d4-a716-446655440000")
* Firecrawl job IDs are UUIDs (v4 or v7)
*/
export function isJobId(str: string): boolean {
// UUID v4 pattern
const uuidPattern =
/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
return uuidPattern.test(str);
}

Expand Down