DEV Community

loading...

Discussion on: Daily Challenge #131 - Remove Anchor from URL

Collapse
deathshadow60 profile image
deathshadow60

The what now? Took me a minute to figure out what this even was...

You're using the wrong terminology. An Anchor is a point on the page that can be linked to or links to another part of the page. Hence the tag <A>nchor.

The number sign in a URI (and yes, it becomes a URI not URL at that point) is called a hash. Everything after the hash is called a "fragment identifier".

... might also help if it said where people are supposed to submit answers. Just post 'em here? Go to the painfully inaccessible codewars? (talk about WCAG violations; sorry, accessibility is my day job)

Though in answering this I'd be really broken between splitting the string with a limit of 2 and throwing away the latter half, or screwing around with strpos and substr. In any valid URI there should only be one # anyways.

Collapse
thepeoplesbourgeois profile image
Josh

You wouldn't even need to limit the split to 2 entries. Maybe it yields a performance improvement, but it should be negligible in all but the hashiest of string cases