-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
✨Pass doc into validator ui using url #20391
Conversation
validator/webui/webui.js
Outdated
|
||
// Extract queryParams from url and return object. | ||
function getSearchParams() { | ||
const {search} = window.location; |
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.
shall we use fragment? since we have #htmlFormat=AMP4ADS
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.
discussed offline, one other reason to use fragment is so that no data is transfer to the server. that in general prevent any potential privacy related issue (PII in the data etc).
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.
Done.
Updated to use fragment. PTAL @honeybadgerdontcare @lannka |
const incomingDocStr = getIncomingDoc(params); | ||
if (incomingDocStr) { | ||
editor.setEditorValue(incomingDocStr); | ||
const format = params['htmlFormat'] || 'AMP4ADS'; |
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 know the intent is to use this for AMP4ADS but right now the default when not specified in the WebUI is AMP and I'd like to stick to that for consistency.
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.
Makes sense. I set the default to AMP
we will just need to tell partners to include htmlFormat=AMP4ADS
Once this is merged and also live in prod, lets document it in the readme |
* read param * use fragment * set default to amp
We have a partner that would like the ability to construct a link to the
validator.ampproject.org
page whereby they can send the document to be validated in the url.This introduces that functionality by passing the document string as a base64 encoded query param, which is then inserted into the text area to be validated.
Due to the
btoa
unicode problem, I opted to use the solution given on this mdn page. The function used for encoding:If you would like an encoded param to use there is one in this gist
This is pending an internal review from the Google security team.