internetarchive / internetarchive/openlibrary

external links without protocol broken for works

Open
#5,443 1 comment 0 reactions 0 assignees View on GitHub
Lead: @jimchamp Priority: 3 Type: Bug
Dominant language
Python
Stars
6.7k
Forks
2k
Avg merge
2d 19h
Merged PRs (30d)
138

Description

If someone adds a link that does not start with `http://` or `https://` to the "links" field of a work it will not be clickable.

### Evidence / Screenshot (if possible)
image

csv of works with non-http links
[non-http-links.csv](https://github.com/internetarchive/openlibrary/files/6837738/non-http-links.csv)

### Relevant url?
https://openlibrary.org/books/OL31995430M/I_Am_Brown_and_Beautiful

with link `www.imaginemecbp.com`

Creates: https://openlibrary.org/books/OL31995430M/www.imaginemecbp.com

### Steps to Reproduce

1. Add a link with a protocol
2. Click on said link

* Actual: link redirects to current page
* Expected: link goes to publisher

### Proposal & Constraints
As far as I can tell, there is no way to force anchor tags to take something like "www.mysite.com" and assume it is an external link. You must prepend the protocol of `http` or `https`.

There are a few things that we can do to address this:
* Stop new bad links from being added
* client side js option - probably good enough but not full proof since JS can be disabled. broader opportunity here to encourage links to be added as identifiers when relevant
* server side validation - I'm not sure what precedent we have for this but I imagine it won't be simple
* Fix the data currently in the DB - currently about 238 books that seem to have this issue
* if http is missing, add it at render time - probably the most hacky but easiest to do

### Related files

### Stakeholders

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.