[Pkg-javascript-devel] Bug#927254: Bug#927254: Bug#927254: closed by Xavier Guimard <yadd at debian.org> (Bug#927254: fixed in vue-router.js 3.0.7+ds-1)

ohw.giles at gmail.com ohw.giles at gmail.com
Wed Jul 22 03:02:34 BST 2020


On Fri, 27 Mar 2020 18:22:23 +0530 Pirate Praveen 
<praveen at onenetbeyond.org> wrote:
 >
 >
 > On Fri, Mar 27, 2020 at 5:20 pm, Pirate Praveen
 > <praveen at onenetbeyond.org> 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.



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-javascript-devel/attachments/20200722/7dff4f63/attachment.html>


More information about the Pkg-javascript-devel mailing list