Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix invalid route in ButtonOutline #3541

1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed warning in product details because of duplicate `product` property in `AddToCompare` mixin - @cewald (#3428)
- Fixed "Clear Wishlist" Button - @dz3n (#3522)
- Fixed hash in dynamically resolved urls causing resolving issues - @lukeromanowicz (#3515)
- Fix invalid routes in ButtonOutline - @lukeromanowicz (#3541)

### Changed / Improved

Expand Down
23 changes: 14 additions & 9 deletions core/lib/multistore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@ export function localizedDispatcherRoute (routeObj: LocalizedRoute | string, sto
}

export function localizedRoute (routeObj: LocalizedRoute | string | RouteConfig | RawLocation, storeCode: string): any {
if (!routeObj) {
Logger.error('Invalid route provided to localize.', null, routeObj)()
return routeObj
}

if (typeof routeObj === 'object') {
if ((routeObj as LocalizedRoute).fullPath && !(routeObj as LocalizedRoute).path) { // support both path and fullPath
routeObj['path'] = (routeObj as LocalizedRoute).fullPath
Expand All @@ -228,18 +233,18 @@ export function localizedRoute (routeObj: LocalizedRoute | string | RouteConfig
return localizedDispatcherRoute(Object.assign({}, routeObj) as LocalizedRoute, storeCode)
}
}
if (storeCode && routeObj && config.defaultStoreCode !== storeCode && config.storeViews[storeCode].appendStoreCode) {
if (typeof routeObj === 'object') {
if (routeObj.name) {
routeObj.name = storeCode + '-' + routeObj.name
}

if (routeObj.path) {
routeObj.path = '/' + storeCode + '/' + (routeObj.path.startsWith('/') ? routeObj.path.slice(1) : routeObj.path)
}
} else {
if (storeCode && config.defaultStoreCode !== storeCode && config.storeViews[storeCode].appendStoreCode) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if somehow config.storeViews[storeCode] would not exist?

if (typeof routeObj !== 'object') {
return '/' + storeCode + routeObj
}
if (routeObj.name) {
routeObj.name = storeCode + '-' + routeObj.name
}

if (routeObj.path) {
routeObj.path = '/' + storeCode + '/' + (routeObj.path.startsWith('/') ? routeObj.path.slice(1) : routeObj.path)
}
}

return routeObj
Expand Down
2 changes: 1 addition & 1 deletion src/themes/default/components/theme/ButtonOutline.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<component
:is="link ? 'router-link' : 'button'"
:to="localizedRoute(link)"
:to="link ? localizedRoute(link) : null"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i believe we shouldn't direct on users such logic; we're returning here the same object, it's not necessary and overcomplication for newcomers.

class="button-outline no-outline py15 bg-cl-transparent h4 no-underline sans-serif fs-medium"
:class="{
light : color === 'light', 'brdr-white' : color === 'light', 'cl-white' : color === 'light',
Expand Down