fix(cafe24): 품목 이미지 주소에 도메인이 두 번 붙어 오는 경우 복구

카페24 GET variants 의 image 가 "https://miras.co.krhttps://cafe24img.poxo.com/
miraskitchen/web/product/extra/big/…" 처럼 쇼핑몰 도메인 뒤에 CDN 전체 주소를
또 붙여 돌려준다(추가이미지를 품목 이미지로 쓴 경우). 그대로 src 에 넣어 깨져
옵션 썸네일이 "없음"으로 보였다. 문자열 안에 http(s):// 가 또 있으면 마지막
주소부터 쓴다.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-28 00:44:20 +09:00
parent 89f055f24b
commit 3882dd7ad3
3 changed files with 9 additions and 1 deletions
@@ -125,7 +125,7 @@
{% endblock %}
{% block scripts %}
<script src="/static/cafe24-options.js?v=20260928b"></script>
<script src="/static/cafe24-options.js?v=20260928c"></script>
<script>
(function () {
var pane = document.getElementById("cf24-editor-pane");
+5
View File
@@ -165,6 +165,11 @@
function imageUrl(path) {
path = String(path || "").trim();
if (!path) return "";
// 카페24 품목 image 가 "https://miras.co.krhttps://cafe24img.poxo.com/…/web/product/extra/big/…"
// 처럼 쇼핑몰 도메인 뒤에 CDN 전체 주소를 한 번 더 붙여 오는 경우가 있다(실물, 추가이미지).
// 안에 주소가 또 있으면 마지막 주소부터 쓴다.
var inner = path.match(/.(https?:\/\/.*)$/i);
if (inner) path = inner[1].replace(/^.*(https?:\/\/)/i, "$1");
if (path.indexOf("//") === 0) return "https:" + path;
if (/^(https?:|data:|blob:)/i.test(path)) return path;
// "/web/product/…" 또는 앞 슬래시 없는 "web/product/…" — 쇼핑몰 주소 기준