On Fri, 27 Mar 2020 18:22:23 +0530 Pirate Praveen <[email protected]> wrote:
>
>
> On Fri, Mar 27, 2020 at 5:20 pm, Pirate Praveen
> <[email protected]> wrote:
> > I can see in dist/vue-router.js
> >
> >  var ref = require("path-to-regexp");
> >  var pathToRegexp = ref.pathToRegexp;
> >
> > and in package.json "path-to-regexp": "^1.7.0",
> >
> > where as we have 6.1.0-2
>
> and exports are different between the versions
>
> in 1.7.0 we have
>
> module.exports = pathToRegexp
> module.exports.parse = parse
> module.exports.compile = compile
> module.exports.tokensToFunction = tokensToFunction
> module.exports.tokensToRegExp = tokensToRegExp
>
> and in 6.1.0
>
> export function pathToRegexp(path, keys, options) {
>     if (path instanceof RegExp)
>         return regexpToRegexp(path, keys);
>     if (Array.isArray(path))
>         return arrayToRegexp(path, keys, options);
>     return stringToRegexp(path, keys, options);
> }
>
> So these two files need to be patched to match the new exports.
>
> src/create-route-map.js:import Regexp from 'path-to-regexp'
> src/util/params.js:import Regexp from 'path-to-regexp'
>
> I have created a patch (replaced current patch to adapt to
> path-to-regexp) and pushed to master. Please test and confirm.
>
>

Unfortunately, it still looks wrong to me. In 3.1.6+ds-1:

 function regexpToRegexp(path, keys) {
     if (!keys)
         { return path; }
     // Use a negative lookahead to match only capturing groups.
     var groups = path.source.match(/\((?!\?)/g);
     if (groups) {
         for (var i = 0; i < groups.length; i++) {
             keys.push({
                 name: i,
                 prefix: "",
                 suffix: "",
                 modifier: "",
                 pattern: ""
             });
         }
     }
     return path;
 }

and in the upstream bundle version 3.1.6:

 function regexpToRegexp (path, keys) {
   // Use a negative lookahead to match only capturing groups.
   var groups = path.source.match(/\((?!\?)/g);

   if (groups) {
     for (var i = 0; i < groups.length; i++) {
       keys.push({
         name: i,
         prefix: null,
         delimiter: null,
         optional: false,
         repeat: false,
         partial: false,
         asterisk: false,
         pattern: null
       });
     }
   }

   return attachKeys(path, keys)
 }

The attachKeys() function is important because it adds a new property to the return value later used by vue-router. Similarly for other functions stringToRegexp, arrayToRegexp. So currently, 3.1.6+ds-1 bundles incompatible versions of vue-router and path-to-regexp.



-- 
Pkg-javascript-devel mailing list
[email protected]
https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/pkg-javascript-devel

Reply via email to