-
Notifications
You must be signed in to change notification settings - Fork 25
Replace jquery-params with URL API and authorize undefined action name #65
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -1,8 +1,22 @@ | ||||||||||
import param from 'jquery-param'; | ||||||||||
import URL from 'url'; | ||||||||||
|
||||||||||
export default function(url, path, queryParams) { | ||||||||||
let query = param(queryParams); | ||||||||||
let pathUrl = url.charAt(url.length - 1) === '/' ? `${url}${path}` : `${url}/${path}`; | ||||||||||
let pathUrl; | ||||||||||
if (path) { | ||||||||||
let maybeMissingSlash = url.endsWith('/') || path.startsWith('/') ? '' : '/' | ||||||||||
pathUrl = `${url}${maybeMissingSlash}${path}`; | ||||||||||
} else { | ||||||||||
pathUrl = url | ||||||||||
} | ||||||||||
|
||||||||||
// 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 commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Are you sure? I'm 99% certain that But yeah, There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 :) |
||||||||||
if (queryParams) { | ||||||||||
Object.keys(queryParams).forEach(key => | ||||||||||
queryObj.set(key, queryParams[key]) | ||||||||||
); | ||||||||||
} | ||||||||||
let query = queryObj.toString(); | ||||||||||
|
||||||||||
return query ? `${pathUrl}?${query}` : pathUrl; | ||||||||||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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:
https://caniuse.com/#search=URLSearchParams