Skip to content

Now encode relative paths as URIs (Escape space as %20, etc) #7

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@
* Missed adding the commit command to the entry points. This means you'd have to run another command first. This is now fixed.

## 0.3.3 - Added notifications

## 0.3.4 - Escape Whitespace

* Whitespace In Paths were previously not escaped, breaking links when repositories has spaces in some filenames
this is now fixed
2 changes: 2 additions & 0 deletions lib/git-links.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ module.exports = GitLinks =
self.git(['rev-parse', '--show-toplevel'], (code, stdout, errors) ->
gitDirectory = stdout.trim()
relativePath = filePath.replace(gitDirectory, '')
relativePath = encodeURI(relativePath)
link = repo + '/blob/' + commitHash + relativePath + '#L' + line
atom.clipboard.write(link)
atom.notifications.addInfo('Copied link for current line to clipboard', detail: link)
Expand All @@ -63,6 +64,7 @@ module.exports = GitLinks =
self.git(['rev-parse', '--show-toplevel'], (code, stdout, errors) ->
gitDirectory = stdout.trim()
relativePath = filePath.replace(gitDirectory, '')
relativePath = encodeURI(relativePath)
link = repo + '/blob/' + commitHash + relativePath
atom.clipboard.write(link)
atom.notifications.addInfo('Copied link for current file to clipboard', detail: link)
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "git-links",
"name": "git-links-plus",
"main": "./lib/git-links",
"version": "0.3.3",
"description": "Get a link to any code hosted in github",
"version": "0.3.5",
"description": "Get a link to any code hosted in github. Previously maintained by calebmeyer",
"keywords": [
"git",
"link",
Expand All @@ -15,7 +15,7 @@
"git-links:copy-absolute-link-for-current-commit"
]
},
"repository": "https://github.com/calebmeyer/git-links",
"repository": "https://github.com/mstr3336/git-links",
"license": "MIT",
"engines": {
"atom": ">=1.0.0 <2.0.0"
Expand Down