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

Isolate URL object #2744

Merged
merged 43 commits into from
Aug 21, 2023
Merged

Isolate URL object #2744

merged 43 commits into from
Aug 21, 2023

Conversation

AntoinePrv
Copy link
Member

@AntoinePrv AntoinePrv commented Aug 10, 2023

  • Hide CURL
  • Refactor URLHandler as a URL class with strong invariant.
  • Manage '%' encoding.
  • Rewrite a number of function to make them independent of CURL /
  • Add many tests
  • Close Wrap curl functions in url files #2611

@AntoinePrv AntoinePrv changed the title Isolate URL object" Isolate URL object Aug 10, 2023
@AntoinePrv AntoinePrv force-pushed the url-object branch 3 times, most recently from c5375e9 to 98cd257 Compare August 11, 2023 14:20
@AntoinePrv AntoinePrv marked this pull request as ready for review August 14, 2023 15:39
@AntoinePrv AntoinePrv self-assigned this Aug 14, 2023
libmamba/include/mamba/util/url.hpp Outdated Show resolved Hide resolved
libmamba/tests/src/util/test_string.cpp Show resolved Hide resolved
libmamba/tests/src/util/test_url.cpp Show resolved Hide resolved
libmamba/tests/src/util/test_url.cpp Show resolved Hide resolved
@AntoinePrv
Copy link
Member Author

I'm merging for moving forward on other PR and fixing the CI, but feel free to add reviews, I will implement them in another PR.

@AntoinePrv AntoinePrv merged commit df918cc into mamba-org:main Aug 21, 2023
@AntoinePrv AntoinePrv deleted the url-object branch August 21, 2023 09:43
@AntoinePrv
Copy link
Member Author

AntoinePrv commented Aug 21, 2023

@Hind-M @Klaim @JohanMabille Do you think it is a good idea to use fs::path as the path component of this URL?
I like the idea of being able to manipulate a path as a path and not a string, but this come with a number of issues on Windows...
If only we had a split Unixpath/WindowsPath/Path like in Python...

@Hind-M
Copy link
Member

Hind-M commented Aug 21, 2023

@Hind-M @Klaim @JohanMabille Do you think it is a good idea to use fs::path as the path component of this URL? I like the idea of being able to manipulate a path as a path and not a string, but this come with a number of issues on Windows... If only we had a split Unixpath/WindowsPath/Path like in Python...

Hmm I guess you won't know if you don't give it a try ^^

@Klaim
Copy link
Member

Klaim commented Aug 21, 2023

Do you think it is a good idea to use fs::path as the path component of this URL?

While I agree it would be nice to have a path type for this, fs::path is designed specifically for filesystem paths and they are not working the same as url paths so I worry that there would be issues. Also internal storage of fs::path is implementation-dependent so thinknig about these like special string can lead to surprising behavior.
However, I wonder how hard would it be to make a very basic url path type just wrapping a std::string (assuming utf-8) ?

@JohanMabille
Copy link
Member

@Hind-M @Klaim @JohanMabille Do you think it is a good idea to use fs::path as the path component of this URL? I like the idea of being able to manipulate a path as a path and not a string ...

I think this would be a wrong good idea ;) Especially when you have API like this one:

        /**
         * Append a sub path to the current path.
         *
         * Contrary to `std::filesystem::path::append`, this always append and never replace
         * the current path, even if @p subpath starts with a '/'.
         */
        auto append_path(std::string_view subpath) -> URL&;

If the path is stored (and returned) as a fs::path object, this would definitely create confusion. Also it is quite easy to build a fs::path from the path component of the URL when it is required / makes sense.

Copy link
Member

@JohanMabille JohanMabille left a comment

Choose a reason for hiding this comment

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

Post merge review: LGTM , nothing to change so far.

cvanelteren pushed a commit to cvanelteren/mamba that referenced this pull request Aug 29, 2023
* Add remove_(prefix|suffix)

* Refactor and document unc_url

* Remove unused functions

* Add CURLUrl wrapper

* Hide CURL from URLHandler

* Rename URLHandler > URL

* Simplify test_url

* Fix path setter

* Add URL builder tests

* Rename URL::url > URL::str

* Rename URL ctor URL::parse

* Refactor has_scheme

* Add get_scheme

* Add scheme option to URL::parse

* Add scheme option to URL::str

* Fix build

* Add has_drive_letter

* Rename and document scheme functions

* Stronger URL invariant

* Rename URL::auth > URL::authentication

* Add URL::authority

* Add URL IP tests

* Document URL

* Fxi rebase util/string

* Fix channel tests

* Allow password without user in URL

* Scope util::URL

* No context in test_url_manip

* Remove unused CURLEasyHandle

* remove declaration

* Add case handling to URL

* Add URL::operator==

* Add URL::operator/

* Test url encoding

* Reimplement URL encoding without CURL

* Fix MSVC

* Add URL::user encoding

* Add URL::password encoding

* Add URL::host encoding

* Add URL::str options

* Small URL imrovement in channel.cpp

* Fix URL auth encoding

* Added review suggestions from @Hind-M
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants