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

Fix the code that incorrectly trim URL. #69

Merged
merged 1 commit into from Feb 18, 2016
Merged

Conversation

sifmelcara
Copy link
Contributor

url.find_first_not_of("telnet://") is wrong.
Any prefix that contain characters in {'t', 'e', 'l', 'n', ':', '/'} will be removed.
For example, "eod.tw" will be trimmed to "od.tw"

url.find_first_not_of("telnet://") is wrong.
Any prefix that contain characters in {'t', 'e', 'l', 'n', ':', '/'} will be removed.
For example, "eod.tw" will be trimmed to "od.tw"
@legnaleurc
Copy link

IMHO std::string::find will be better.

    const string telnetPrefix = "telnet://";
    if (url.find(telnetPrefix) == 0)
        url.erase(0, telnetPrefix.size());

@kidwm
Copy link
Member

kidwm commented Feb 17, 2016

@legnaleurc Nice shot!
@sifmelcara how about you?

@sifmelcara
Copy link
Contributor Author

I think substr() has better readability and speed(in worst case) in this case.
However, I do not care things other than correctness much.

kidwm added a commit that referenced this pull request Feb 18, 2016
Fix the code that incorrectly trim URL.
@kidwm kidwm merged commit 7777b7a into pcman-bbs:master Feb 18, 2016
@david50407
Copy link

When will this patch release?
cc @kidwm

@kidwm
Copy link
Member

kidwm commented Mar 19, 2018

I forgot to ask @fourdollars about this yesterday

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.

None yet

4 participants