mirror of
https://github.com/standardebooks/web.git
synced 2025-07-16 11:26:37 -04:00
When adding an artwork ebook URL, confirm that that ebook exists
This commit is contained in:
parent
f8a050486b
commit
e85d833bad
1 changed files with 8 additions and 4 deletions
|
@ -496,11 +496,15 @@ class Artwork{
|
|||
}
|
||||
|
||||
// Check the ebook URL.
|
||||
// We don't check if it exists, because the book might not be published yet.
|
||||
// But we do a basic check that URL has the correct prefix and that it contains a slash between the author(s) and title.
|
||||
if($this->EbookUrl !== null){
|
||||
if(!preg_match('|^https://standardebooks.org/ebooks/[^/]+?/[^/]+?|ius', $this->EbookUrl)){
|
||||
$error->Add(new Exceptions\EbookNotFoundException('Invalid ebook URL. Check that it matches the URL in dc:identifier.'));
|
||||
try{
|
||||
Ebook::GetByIdentifier('url:' . $this->EbookUrl);
|
||||
|
||||
// Ebook found, continue.
|
||||
}
|
||||
catch(Exceptions\EbookNotFoundException){
|
||||
// Ebook not found, error!
|
||||
$error->Add(new Exceptions\EbookNotFoundException('Couldn’t find an ebook with that URL.'));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue