Skip to content

Commit 80ea119

Browse files
committed
fix(tools): fixed routes for demo sub directories
1 parent d3d47d1 commit 80ea119

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

tools/pfe-tools/dev-server/config.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,22 +118,21 @@ function pfeDevServerPlugin(options: PfeDevServerInternalConfig): Plugin {
118118
ctx.redirect(`/${componentSubpath}/${ctx.params.componentDir}/${ctx.params.fileName}.ts`);
119119
})
120120
// Redirect `elements/jazz-hands/demo/*.js|css` to `elements/pf-jazz-hands/demo/*.js|css`
121+
// If request is `elements/jazz-hands/demo/some-other-demo/*.js|css redirect files to `elements/pf-jazz-hands/demo/*.js|css`
121122
.get(`/${componentSubpath}/:componentDir/demo/:demoSubDir?/:fileName.:ext`, async (ctx, next) => {
122123
if (!ctx.params.componentDir.includes(tagPrefix)) {
123-
const demoSubDir = ctx.params.demoSubDir ? `${ctx.params.demoSubDir}/` : '';
124-
ctx.redirect(`/${componentSubpath}/${tagPrefix}-${ctx.params.componentDir}/demo/${demoSubDir}${ctx.params.fileName}.${ctx.params.ext}`);
124+
ctx.redirect(`/${componentSubpath}/${tagPrefix}-${ctx.params.componentDir}/demo/${ctx.params.fileName}.${ctx.params.ext}`);
125125
} else {
126126
return next();
127127
}
128128
})
129129
// Redirect `elements/jazz-hands/*` to `elements/pf-jazz-hands/*` for files not previously handled
130130
.get(`/${componentSubpath}/:componentDir/:any*`, async (ctx, next) => {
131-
if (ctx.params.any === 'demo') {
131+
if (ctx.params.any.includes('demo')) {
132132
/* if its the demo directory return */
133133
return next();
134134
}
135135
if (!ctx.params.componentDir.includes(tagPrefix)) {
136-
console.log(`redirecting ${ctx.request.url} to /${componentSubpath}/${tagPrefix}-${ctx.params.componentDir}/${ctx.params.any}`);
137136
ctx.redirect(`/${componentSubpath}/${tagPrefix}-${ctx.params.componentDir}/${ctx.params.any}`);
138137
} else {
139138
return next();

0 commit comments

Comments
 (0)