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

Assigning segments_ref to segments_ref #520

Open
vinniefalco opened this issue Sep 9, 2022 · 4 comments
Open

Assigning segments_ref to segments_ref #520

vinniefalco opened this issue Sep 9, 2022 · 4 comments
Labels
Design Design input needed

Comments

@vinniefalco
Copy link
Member

Consider the following:

url u1( "/index%2Ehtm" );
url u2( "/path/to/file%2Etxt" );
segments_ref ps1 = u1.segments();
segments_ref Type ps2 = u2.segments();
ps1 = p2;

What should the contents of ps1 be? Well, operator= is documented with this effect:

ps1.assign( ps2.begin(), p2.end() );

Iterating ps2 will produce decoded segments, so ps1 will end up with

{ "path", "to", "file.txt" }

Note how "file.txt" has the escape removed. This behavior is technically correct according to our specification but is this the right thing to do?

@vinniefalco vinniefalco added the Design Design input needed label Sep 9, 2022
@vinniefalco
Copy link
Member Author

@pdimov any idears?

@pdimov
Copy link
Member

pdimov commented Sep 12, 2022

Yes it's the right thing to do.

@pdimov
Copy link
Member

pdimov commented Sep 12, 2022

Even more interesting is u1.segments() = u1.segments();, which should do the same (that is, remove any unnecessary percent encoding.)

Not sure about u1.segments().back() = u1.segments().back();. Does this work?

@vinniefalco
Copy link
Member Author

vinniefalco commented Sep 12, 2022

Not sure about u1.segments().back() = u1.segments().back();. Does this work?

No, because back() just returns a string. Assignment can't work for elements, since iterators don't return modifiable references to the underlying element.

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

No branches or pull requests

2 participants