iron-meteor / iron-url Goto Github PK
View Code? Open in Web Editor NEWUrl utilities and support for compiling a url into a regular expression.
License: MIT License
Url utilities and support for compiling a url into a regular expression.
License: MIT License
Url.parse('/route/:_id/:slug?') don't handle the '?' part well,
it strips the '?' part and handle everything after it as query string or something.
Url.parse('/route/:_id?/:slug?') returns {..., pathname: '/route/:_id', path: '/route/:_id?/:slug?',...}
and pathname is used by normalize and other stuff that breaks optional params routing in iron:router.
I took a look at the code but I lack the in-depth knowledge to actually try and make a PR that might work with this and not skrew up the support for the old school hash frag support. Maybe I'm overthinking this but you know...
edit: Mixed up pathname and path, it's fixed now. The information is correct now
I don't use wildcard in routes; simply define a route
Router.route("/user/:id?", {
name: "userInfo",
template: "...",
layoutTemplate: "...",
});
and use
Router.routes.userInfo.path({
id: Meteor.user().username
});
Then if I have the user name a*a
, Router.routes.userInfo.path
throws an exception You are trying to access a wild card parameter at index 0 but but the value of params at that index is undefined
Stack trace:
Any wildcard in a params will result in this.
Following up on #1, it would be nice for iron-url to support more styles:
/path?foo[]=a&foo[]=b
parsed into this.params.foo === ['a', 'b']
/path?foo=a&foo=b
parsed into this.params.foo === ['a', 'b']
/path?foo[]=a
parsed into this.params.foo === ['a']
/path?foo=a
parsed into this.params.foo === 'a'
Express uses qs to do this: https://github.com/hapijs/qs/blob/master/test/parse.js#L73
I believe this line is causing the issue, which is basically that the base64 padding at the end of a string (==
) is being removed from the value.
So (using bogus base64 value for point), you might expect ?data=DgxfQ==
to produce {data: 'DgxfQ=='}
, but instead it produces {data: 'DgxfQ'}
.
Instead of pair.split('=')
, perhaps something like this would work more reliably, though I suspect it's a bit more expensive:
idx = pair.indexOf('=');
key = pair.substr(0, idx);
value = pair.substr(idx+1);
I'd hoped pair.split('=', 2)
would do the trick, but that truncates the trailing ==
as well.
...has anyone thanked you for your work recently? Either way, many thanks ;)
Isn't the name field missing in package.js
and the git url incorrect? There's probably a reason, but I'd like to know the status of this package. Thanks ๐
The plan is to use rail's style, and have URLs of the form
/path?foo[]=a&foo[]=b
To end up with this.params.foo === ['a', 'b']
.
The alternative is /path?foo=a&foo=b
. But the downside there is you can't do a single element array, which is sucky. Either way you can't do a zero-element array. Not sure if there's anything principled that can be done about this.
Let me know if you want me to go ahead with this.
I think this should throw an exception.
URLs with authorization present get lowercased, causing passwords to become corrupted for case-sensitive systems.
My route looks like this:
Router.map(function() {
this.route('ship.parcel.addressChooser', {path: '/ship/choose-address/:_id',});
});
And I call Router.go() like this:
Router.go('ship.parcel.addressChooser', {_id: parcelId});
The parcelId is a string that equals PP-dev-KrdGbz
The resulting url that I get sent to ends up being this: http://localhost:3002/ship/choose-address/undefinedPP-dev-KrdGbz
You can see that there is an extra undefined
in that URL. When going deep into my debugger, I found the following:
Basically, the parameter format
is undefined, which then gets appended as a string to the final path. I'm not sure what the purpose of that match parameter is, but it seems like you could just do the same thing that you are doing with the slash
match parameter here right below that line like this: format = format || '';
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.