feat(validation): relax Instagram URL validation to support all content types
- Create validateInstagramUrl utility using URL constructor - Replace regex-based validation with hostname and protocol checks - Support posts, reels, IGTV, and URLs with query parameters - Add comprehensive unit tests (22 tests, all passing) - Add integration tests for new URL formats - Update API documentation with supported URL formats Closes: #RelaxInstagramUrlValidation
This commit is contained in:
31
docs/API.md
31
docs/API.md
@@ -51,11 +51,36 @@ Enqueue an Instagram URL for async processing.
|
||||
}
|
||||
```
|
||||
|
||||
**Supported URL Formats:**
|
||||
- Posts: `https://instagram.com/p/{post-id}`
|
||||
- Posts (www): `https://www.instagram.com/p/{post-id}`
|
||||
- Reels: `https://instagram.com/reel/{reel-id}`
|
||||
- IGTV: `https://instagram.com/tv/{video-id}`
|
||||
- With query parameters: `https://instagram.com/reel/{reel-id}?utm_source=share`
|
||||
|
||||
**URL Requirements:**
|
||||
- Must use HTTPS protocol
|
||||
- Hostname must be `instagram.com` or `www.instagram.com`
|
||||
- Any Instagram path is accepted (posts, reels, IGTV, etc.)
|
||||
- Query parameters and hash fragments are allowed
|
||||
|
||||
**Examples:**
|
||||
```json
|
||||
// Post URL
|
||||
{ "url": "https://instagram.com/p/ABC123" }
|
||||
|
||||
// Reel URL with tracking
|
||||
{ "url": "https://www.instagram.com/reel/DSevV5CDcNm/?utm_source=ig_web_copy_link" }
|
||||
|
||||
// IGTV URL
|
||||
{ "url": "https://instagram.com/tv/XYZ789" }
|
||||
```
|
||||
|
||||
**Response (201 Created):**
|
||||
```json
|
||||
{
|
||||
"id": "550e8400-e29b-41d4-a716-446655440000",
|
||||
"url": "https://instagram.com/p/abc123",
|
||||
"url": "https://instagram.com/reel/DSevV5CDcNm/?utm_source=ig_web_copy_link",
|
||||
"status": "pending",
|
||||
"phases": [
|
||||
{
|
||||
@@ -80,7 +105,9 @@ Enqueue an Instagram URL for async processing.
|
||||
```
|
||||
|
||||
**Errors:**
|
||||
- `400` - Invalid Instagram URL format
|
||||
- `400` - Invalid URL format (not a valid URL)
|
||||
- `400` - URL must use HTTPS protocol
|
||||
- `400` - URL must be from instagram.com domain
|
||||
- `400` - Missing or invalid URL parameter
|
||||
|
||||
### GET /api/queue
|
||||
|
||||
Reference in New Issue
Block a user