vue-router-sitemap icon indicating copy to clipboard operation
vue-router-sitemap copied to clipboard

applyParams method of VueRouterSitemap uses undefined applyParams function

Open mbarouski opened this issue 3 years ago • 1 comments

./src/index.js:

class VueRouterSitemap {
  // ...
  applyParams(paramsConfig) {
    this.paths = applyParams(this.paths, paramsConfig);
    return this;
  }
  // ...
}

Moreover, applyParams is not implemented in the project at all. So the issue requests implementation of the function.

mbarouski avatar Apr 08 '21 09:04 mbarouski

Solved it this way:

VueRouterSitemap.prototype.applyParams = function applyParams(params) {
  this.paths = this.paths.map(p => ({
    path: Object.keys(params).reduce((acc, curr) => {
      return acc.replace(curr, params[curr]);
    }, p.path)
  }));
  return this;
};

mbarouski avatar Apr 08 '21 10:04 mbarouski