-
Notifications
You must be signed in to change notification settings - Fork 12
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
feat: add functionality to optionally disable path encoding #98
Conversation
Features
Tests
Documentation
Code Refactoring
ContributorsCommit-Lint commandsYou can trigger Commit-Lint actions by commenting on this PR:
|
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.
Hey @ashutoshkrris, thanks again for taking the time to clean up those commits and open a new PR. This is looking great!
Unfortunately, CI is failing because our linter, flake8
, is taking issues with some of the syntaxes. That's not your fault, our tests don't run flake8
locally so you wouldn't have known. We need to document that better.
Do you think you could address the issues flake8
is raising on CI? Namely:
imgix/urlbuilder.py:41:80: E501 line too long (87 > 79 characters)
tests/test_url_builder.py:30:80: E501 line too long (86 > 79 characters)
tests/test_url_builder.py:178:1: E302 expected 2 blank lines, found 1
tests/test_url_builder.py:178:80: E501 line too long (82 > 79 characters)
tests/test_url_builder.py:185:80: E501 line too long (85 > 79 characters)
tests/test_srcset.py:137:80: E501 line too long (90 > 79 characters)
tests/test_srcset.py:141:11: E275 missing whitespace after keyword
tests/test_srcset.py:145:80: E501 line too long (90 > 79 characters)
tests/test_srcset.py:149:11: E275 missing whitespace after keyword
One quick way to do this would be to use black
, a python auto-formatter. In the root of your project fork, could do run something like:
# install black
pip install black
# run black on the files that have linting issues with max line-length set to 79
# ie, black --line-length 79 {source_file_or_directory}
black --line-length 79 tests/test_url_builder.py
# make sure you have no more flake8 issues
tox -e flake8
Thanks for the feedback @luqven |
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.
Hey @ashutoshkrris,
Thanks for your prompt work on this, it's coming along nicely!
I did get some feedback from the team, and we're leaning toward doing this functionally rather than in a class setting. IE, the options
accepted as an optional parameter in create_url
.
def create_url(self, path="", params={}, options={}):
Where options
would accept disablePathEncoding
.
I apologize for asking you to change the approach here after all your hard work. I failed to consider the inconsistency that creating a class setting would create with our other SDKs, where this is handled functionally.
If it's not too much trouble, would you mind refactoring your approach to instead add disablePathEncoding
to create_url
? I'm happy to clarify that further if it's unclear why I'm asking for this change.
I want to be respectful of your time so if you'd rather one of the team members handle this change you can always opt to give us push permissions to your fork and we'll take this the rest of the way.
Again thank you for the work you've put into this, it's been very helpful.
…te_url() and create_srcset() functions
Hi @luqven |
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.
Things are looking great!
I left you some small questions and will take this back to the team. I'll come back and review the PR after we've had a chance to discuss it.
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.
Description
Before this PR, this library would encode all paths passed to either
create_url()
orcreate_srcset()
. This was a great default in a lot of scenarios, but this proved to be irritating when integrating with some data sources that provided already encoded URL paths.After this PR, the library would allow users to optionally pass a options parameter containing
disable_path_encoding
having boolean value.Steps to test
Testing the
create_url()
methodNormally this would output a source URL like
https://sdk-test.imgix.net/%20%3C%3E%5B%5D%7B%7D%7C%5E%25.jpg?h=100&2=100
, but since path encoding is disabled, it will output a source URL likehttps://sdk-test.imgix.net/ <>[]{}|^%.jpg?h=100&w=100
.Testing the
create_scrset()
methodNormally this would output a source URL like
https://sdk-test.imgix.net/image%3C%3E%5B%5D%7B%7D%20123.png?&w=100 100w
, but since path encoding is disabled, it will output a source URL likehttps://sdk-test.imgix.net//image<>[]{} 123.png?&w=100 100w
.Checklist
BREAKING CHANGE
in the body of the commit.