Spaces:
Running
Running
save even if no image
Browse files
src/routes/api/scrap-models/[slug]/+server.ts
CHANGED
|
@@ -42,14 +42,11 @@ export async function POST({ request, params }) {
|
|
| 42 |
const imageRegex = /!\[.*\]\((.*)\)/
|
| 43 |
let image = readme.match(imageRegex)?.[1]
|
| 44 |
|
| 45 |
-
if (
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
}
|
| 50 |
-
image = image.replace(///g, "/")
|
| 51 |
-
if (image.startsWith("http")) model.image = image
|
| 52 |
-
else model.image = `https://huggingface.co/${model.id}/resolve/main/${image.replace("./", "")}`
|
| 53 |
}
|
| 54 |
}
|
| 55 |
}
|
|
|
|
| 42 |
const imageRegex = /!\[.*\]\((.*)\)/
|
| 43 |
let image = readme.match(imageRegex)?.[1]
|
| 44 |
|
| 45 |
+
if (image) {
|
| 46 |
+
image = image.replace(///g, "/")
|
| 47 |
+
if (image.startsWith("http")) model.image = image
|
| 48 |
+
else model.image = `https://huggingface.co/${model.id}/resolve/main/${image.replace("./", "")}`
|
| 49 |
}
|
|
|
|
|
|
|
|
|
|
| 50 |
}
|
| 51 |
}
|
| 52 |
}
|