Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

refactor localizedPathFor function for api addresses

KacperMekarskid2c18ae5cf86
diff --git a/core/app/assets/javascripts/spree.js b/core/app/assets/javascripts/spree.js
index 484408ca00..e29686491b 100644
--- a/core/app/assets/javascripts/spree.js
+++ b/core/app/assets/javascripts/spree.js
@@ -25,16 +25,16 @@ Spree.localizedPathFor = function(path) {
if (typeof (SPREE_LOCALE) !== 'undefined' && typeof (SPREE_CURRENCY) !== 'undefined') {
var fullUrl = new URL(Spree.pathFor(path))
var params = fullUrl.searchParams
- var pathName = path
+ var pathName = fullUrl.pathname
params.set('currency', SPREE_CURRENCY)
if (pathName.match(/api\/v/)) {
params.set('locale', SPREE_LOCALE)
} else {
- pathName = SPREE_LOCALE + '/' + path
+ pathName = (this.mountedAt()) + SPREE_LOCALE + '/' + path
}
- return fullUrl.origin + (this.mountedAt()) + pathName + '?' + params.toString()
+ return fullUrl.origin + pathName + '?' + params.toString()
}
return Spree.pathFor(path)
}