-
Notifications
You must be signed in to change notification settings - Fork 29
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
Allow external links for consensus-specs repo #52
Conversation
@@ -25,13 +25,15 @@ impl Lint for RelativeLinks { | |||
fn lint<'a, 'b>(&self, slug: &'a str, ctx: &Context<'a, 'b>) -> Result<(), Error> { | |||
let re = Regex::new("(^/)|(://)").unwrap(); | |||
|
|||
let cs_re = Regex::new(r"^https://(www\.)?github\.com/ethereum/consensus-specs(/|$)").unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have the additional requirement that links to consensus specs include a specific commit, so this should only match URLs like:
https://github.com/ethereum/consensus-specs/blob/26695a9fdb747ecbe4f0bb9812fedbc402e5e18c/...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't aware, sorry about that. I will add it, just let me verify - it should point to a version of a file at some commit, therefore it has to be ../blob/..
or the commit itself, which would be .../commit/..
?
Are there any other rules to follow? For example prefix, currently it allows all combinations with https://
or www
or without
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should've mentioned earlier! It's entirely my bad.
I suppose the best option would be https
only, allow both with and without the www
.
Links should go to specific files at a specific commit, so I think .../blob/...
is what we want.
Added more restrictive rules and tested on all possible combinations. Now it only allows relative paths and URLs in format |
@@ -23,15 +23,19 @@ pub struct RelativeLinks; | |||
|
|||
impl Lint for RelativeLinks { | |||
fn lint<'a, 'b>(&self, slug: &'a str, ctx: &Context<'a, 'b>) -> Result<(), Error> { | |||
let re = Regex::new("(^/)|(://)").unwrap(); | |||
let re = Regex::new(r"(^/)|(://)|(^www)|^(\w)+\.(\w)+").unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this treat [hello](www)
as a relative link?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, that is not allowed, should it work? I can specify it as www
in front of a domain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think [hello](www)
will turn into hello. On this particular PR that expands to https://github.com/ethereum/eipw/pull/www
.
Adds exception in the lint for relative links. Quick solution with additional regex allows links pointing to github.com/ethereum/consensus-specs.