Complete the function/method so that it returns the url with anything after the anchor (#) removed.
Examples
remove_url_anchor('dev.to#...
For further actions, you may consider blocking this person and/or reporting abuse
Haskell:
So much beautiful to read.
Here is the simple solution with
parse_url
function in PHP:Java:
REGEX to the rescue.
C# solution
JavaScript
Second parameter to
split
means it will stop looking after the first match, and never construct a second string value.Rust
look at it go!
Disclaimer:
In real life, please use developer.mozilla.org/docs/Web/API... or docs.rs/url/ respectively.
These should be fairly bulletproof though, since URL specification doesn't allow unencoded
#
character anywhere, including notably the<password>
section of<protocol>://<user>:<password>@<host>
. But where there's fragment, soon will come other parts of the URL.js using split method
JS
Python:
SQL (postgres)
const remove_url_anchor =(url) => url && url.split('#')[0];
Ha! I love the English like precision in syntax.