Skip to content
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

amp-bind: Expose encodeURI and encodeURIComponent in bind #8723

Merged
merged 4 commits into from Apr 14, 2017

Conversation

kmh287
Copy link
Contributor

@kmh287 kmh287 commented Apr 12, 2017

Adds support for encodeURI and encodeURIComponent in bind.

Partial for #8700

/to @choumx

Copy link

@dreamofabear dreamofabear left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update amp-bind.md.

@@ -268,6 +268,11 @@ describe('BindExpression', () => {
}).to.throw(unsupportedFunctionError);
});

it('should support encodeURI and encodeURIComponent', () => {
expect(evaluate('encodeURI("Hello World")')).to.equal('Hello%20World');
expect(evaluate('encodeURIComponent("#foo=bar")')).to.equal('%23foo%3Dbar');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a fragment or URL params? We should test the latter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor Author

@kmh287 kmh287 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done 👍

@@ -268,6 +268,11 @@ describe('BindExpression', () => {
}).to.throw(unsupportedFunctionError);
});

it('should support encodeURI and encodeURIComponent', () => {
expect(evaluate('encodeURI("Hello World")')).to.equal('Hello%20World');
expect(evaluate('encodeURIComponent("#foo=bar")')).to.equal('%23foo%3Dbar');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

expect(evaluate('encodeURI("http://www.google.com/s p a c e.html")'))
.to.equal('http://www.google.com/s%20p%20a%20c%20e.html');
expect(evaluate('encodeURIComponent("hello world")'))
.to.equal('hello%20world');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: This test for encodeURIComponent tests the same functionality as the one for encodeURI. Recommend testing proper encoding for some of these chars: ; , / ? : @ & = + $ #

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that's necessary. We don't need to test the correctness of the functions, just that using them in bind expressions works.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correctness is currently an implementation detail. 😄 It is a nitpick though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants