validation: ensure seed urls, and other url properties, are validated on POST by using pydantic HttpUrl type, fixes #277 (#278)
This commit is contained in:
parent
3fec2a9f82
commit
50c525853f
@ -10,7 +10,7 @@ import re
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
import pymongo
|
import pymongo
|
||||||
from pydantic import BaseModel, UUID4, conint
|
from pydantic import BaseModel, UUID4, conint, HttpUrl
|
||||||
from fastapi import APIRouter, Depends, HTTPException
|
from fastapi import APIRouter, Depends, HTTPException
|
||||||
|
|
||||||
from .users import User
|
from .users import User
|
||||||
@ -35,12 +35,12 @@ class ScopeType(str, Enum):
|
|||||||
class Seed(BaseModel):
|
class Seed(BaseModel):
|
||||||
"""Crawl seed"""
|
"""Crawl seed"""
|
||||||
|
|
||||||
url: str
|
url: HttpUrl
|
||||||
scopeType: Optional[ScopeType] = ScopeType.PREFIX
|
scopeType: Optional[ScopeType] = ScopeType.PREFIX
|
||||||
|
|
||||||
include: Union[str, List[str], None]
|
include: Union[str, List[str], None]
|
||||||
exclude: Union[str, List[str], None]
|
exclude: Union[str, List[str], None]
|
||||||
sitemap: Union[bool, str, None]
|
sitemap: Union[bool, HttpUrl, None]
|
||||||
allowHash: Optional[bool]
|
allowHash: Optional[bool]
|
||||||
depth: Optional[int]
|
depth: Optional[int]
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ class Seed(BaseModel):
|
|||||||
class RawCrawlConfig(BaseModel):
|
class RawCrawlConfig(BaseModel):
|
||||||
"""Base Crawl Config"""
|
"""Base Crawl Config"""
|
||||||
|
|
||||||
seeds: List[Union[str, Seed]]
|
seeds: List[Union[HttpUrl, Seed]]
|
||||||
|
|
||||||
scopeType: Optional[ScopeType] = ScopeType.PREFIX
|
scopeType: Optional[ScopeType] = ScopeType.PREFIX
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user