Store brand color without # prefix, normalize on output

saveBrandColor.cfm no longer prepends # before storing. API responses
(get.cfm, items.cfm, getForBuilder.cfm) prepend # if missing so
consumers always get a CSS-ready value.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
John Mizerek 2026-01-28 14:58:58 -08:00
parent 8f9da2fbf0
commit cc96d891b2
4 changed files with 5 additions and 5 deletions

View file

@ -141,7 +141,7 @@ try {
"IsHiring": q.BusinessIsHiring == 1,
"TaxRate": taxRate,
"TaxRatePercent": taxRate * 100,
"BrandColor": len(q.BusinessBrandColor) ? q.BusinessBrandColor : ""
"BrandColor": len(q.BusinessBrandColor) ? (left(q.BusinessBrandColor, 1) == chr(35) ? q.BusinessBrandColor : chr(35) & q.BusinessBrandColor) : ""
};
// Add header image URL if extension exists

View file

@ -47,8 +47,8 @@ if (len(brandColor) GT 0) {
if (len(brandColor) != 6 || !reFind("^[0-9A-Fa-f]{6}$", brandColor)) {
apiAbort({ "OK": false, "ERROR": "invalid_color", "MESSAGE": "Color must be a valid 6-digit hex color (e.g. 1B4D3E or ##1B4D3E)" });
}
// Store with # prefix, uppercase
brandColor = chr(35) & uCase(brandColor);
// Store uppercase, no # prefix
brandColor = uCase(brandColor);
}
// Update the database

View file

@ -411,7 +411,7 @@ try {
SELECT BusinessBrandColor FROM Businesses WHERE BusinessID = :bizId
", { bizId: businessID }, { datasource: "payfrit" });
if (qBrand.recordCount > 0 && len(trim(qBrand.BusinessBrandColor))) {
brandColor = qBrand.BusinessBrandColor;
brandColor = left(qBrand.BusinessBrandColor, 1) == chr(35) ? qBrand.BusinessBrandColor : chr(35) & qBrand.BusinessBrandColor;
}
} catch (any e) {
// Column may not exist yet, ignore

View file

@ -497,7 +497,7 @@
{ datasource = "payfrit" }
)>
<cfif qBrand.recordCount GT 0 AND len(trim(qBrand.BusinessBrandColor))>
<cfset brandColor = qBrand.BusinessBrandColor>
<cfset brandColor = left(qBrand.BusinessBrandColor, 1) EQ chr(35) ? qBrand.BusinessBrandColor : chr(35) & qBrand.BusinessBrandColor>
</cfif>
<cfcatch>
<!--- Column may not exist yet, ignore --->