-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace jquery-params with URL API and authorize undefined action name #65
base: master
Are you sure you want to change the base?
Conversation
addon/utils/url-builder.js
Outdated
let pathUrl = url.charAt(url.length - 1) === '/' ? `${url}${path}` : `${url}/${path}`; | ||
|
||
return query ? `${pathUrl}?${query}` : pathUrl; | ||
let urlObj = new URL(url, 'https://example.com'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if the url is absolute? Previously this function always returned absolute URL, while now its relative.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps I'm the one who led us down the wrong path here, in my previous comment.
If url
is always absolute something like let urlObj = new URL(url);
should work, along with return urlObj.toString();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm editing the PR in order to use native URL API only for queryParams and keep something more raw for the pathUrl to avoid conflict with absolute/relative URLs
Thanks for your feedbacks
8314cd7
to
44c8ada
Compare
44c8ada
to
8f070c0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
@@ -1,8 +1,22 @@ | |||
import param from 'jquery-param'; | |||
import URL from 'url'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could add a note about this being a polyfill and that when Ember drop support for IE 11 this won't be needed anymore:
} | ||
|
||
// Use native URL API to generate query | ||
let queryObj = new URL('https://exelord.com/ember-custom-actions/').searchParams; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let queryObj = new URL('https://exelord.com/ember-custom-actions/').searchParams; | |
// Passing in example.com because a domain is needed, but we're not using it. | |
// Using `URL` only to access the queryParams API. | |
let queryObj = new URL('https://example.com').searchParams; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://host.test
- never use .com
it fires DNS lookup, which allows track where the request is coming from.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure? I'm 99% certain that new URL('https://example.com')
won't fire any DNS lookups. It's just a bunch of string operations.
But yeah, .test
should also work well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case we won't render it that's true. But just to prevent that issue in the future is better to forget about .com's for examples :)
Following #53
Hello,
This PR is here to be able to used unamed action :)
And I take a look into buildUrl mixin to replace jquery-params by the native URL API.
There is a polyfills for old browser thanks to ember-url (because URL polyfills is not handle by babel).
ping @sandstrom