Skip to content

Instantly share code, notes, and snippets.

@timwco
Last active December 9, 2016 20:52
Show Gist options
  • Select an option

  • Save timwco/aaf75cdb3e2ca0481cb0 to your computer and use it in GitHub Desktop.

Select an option

Save timwco/aaf75cdb3e2ca0481cb0 to your computer and use it in GitHub Desktop.

Revisions

  1. timwco revised this gist May 7, 2015. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions ghregex.js
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@ javascript: (function() {
    location.href = s.replace(r, "http:/$5.github.io/$6");
    })();

    // URL Encoded Version (for bookmark links)
    // URL Encoded Version (for use as a bookmarklet)
    javascript:(function()%7Bvar s%3Dlocation.href%3Bvar r%3D/%5E((http%5Bs%5D%3F%7Cftp):%5C/)%3F%5C/%3F(%5B%5E:%5C/%5Cs%5D%2B)((%5C/%5Cw%2B)*%5C/)(%5B%5Cw%5C-%5C.%5D%2B%5B%5E%23%3F%5Cs%5D%2B)(.*)%3F(%23%5B%5Cw%5C-%5D%2B)%3F%24/g%3Blocation.href%3Ds.replace(r,"http:/%245.github.io/%246")%3B%7D)()%3B

    /*
    @@ -19,5 +19,5 @@ javascript: (function() {
    location.href = s.replace(r, "https://github.com/$3/$8");
    })();

    // URL Encoded Version (for bookmark links)
    // URL Encoded Version (for use as a bookmarklet)
    javascript:(function()%7Bvar%20s%20%3D%20location.href%3Bvar%20r%20%3D%20%2F%5E((http%5Bs%5D%3F%7Cftp)%3A%5C%2F)%3F%5C%2F%3F(%5B%5E%3A%5C.%5Cs%5D%2B).(%5B%5E%3A%5C.%5Cs%5D%2B).(%5B%5E%3A%5C%2F%5Cs%5D%2B)((%5C%2F%5Cw%2B)*%5C%2F)(%5B%5Cw%5C-%5C.%5D%2B%5B%5E%23%3F%5Cs%5D%2B)(.*)%3F(%23%5B%5Cw%5C-%5D%2B)%3F%24%2Fg%3Blocation.href%20%3D%20s.replace(r,"https://github.com/$3/$8")%3B%7D)()%3B
  2. timwco created this gist May 7, 2015.
    23 changes: 23 additions & 0 deletions ghregex.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    /*
    Takes you from a Github Repo URL to the GH Pages version on github.io
    */
    javascript: (function() {
    var s = location.href;
    var r = /^((http[s]?|ftp):\/)?\/?([^:\/\s]+)((\/\w+)*\/)([\w\-\.]+[^#?\s]+)(.*)?(#[\w\-]+)?$/g;
    location.href = s.replace(r, "http:/$5.github.io/$6");
    })();

    // URL Encoded Version (for bookmark links)
    javascript:(function()%7Bvar s%3Dlocation.href%3Bvar r%3D/%5E((http%5Bs%5D%3F%7Cftp):%5C/)%3F%5C/%3F(%5B%5E:%5C/%5Cs%5D%2B)((%5C/%5Cw%2B)*%5C/)(%5B%5Cw%5C-%5C.%5D%2B%5B%5E%23%3F%5Cs%5D%2B)(.*)%3F(%23%5B%5Cw%5C-%5D%2B)%3F%24/g%3Blocation.href%3Ds.replace(r,"http:/%245.github.io/%246")%3B%7D)()%3B

    /*
    Takes you from a GH Pages URL to the Github Repo
    */
    javascript: (function() {
    var s = location.href;
    var r = /^((http[s]?|ftp):\/)?\/?([^:\.\s]+).([^:\.\s]+).([^:\/\s]+)((\/\w+)*\/)([\w\-\.]+[^#?\s]+)(.*)?(#[\w\-]+)?$/g;
    location.href = s.replace(r, "https://github.com/$3/$8");
    })();

    // URL Encoded Version (for bookmark links)
    javascript:(function()%7Bvar%20s%20%3D%20location.href%3Bvar%20r%20%3D%20%2F%5E((http%5Bs%5D%3F%7Cftp)%3A%5C%2F)%3F%5C%2F%3F(%5B%5E%3A%5C.%5Cs%5D%2B).(%5B%5E%3A%5C.%5Cs%5D%2B).(%5B%5E%3A%5C%2F%5Cs%5D%2B)((%5C%2F%5Cw%2B)*%5C%2F)(%5B%5Cw%5C-%5C.%5D%2B%5B%5E%23%3F%5Cs%5D%2B)(.*)%3F(%23%5B%5Cw%5C-%5D%2B)%3F%24%2Fg%3Blocation.href%20%3D%20s.replace(r,"https://github.com/$3/$8")%3B%7D)()%3B