Last active
March 15, 2017 20:15
-
-
Save denisenepraunig/d831fa7bdab4b486c3a2dfe2393309dc to your computer and use it in GitHub Desktop.
decode URLs - %20 and %27
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use babel'; | |
import SimpleUrlDecoderView from './simple-url-decoder-view'; | |
import { CompositeDisposable } from 'atom'; | |
export default { | |
subscriptions: null, | |
activate(state) { | |
// Events subscribed to in atom's system can be easily cleaned up with a CompositeDisposable | |
this.subscriptions = new CompositeDisposable(); | |
// Register command | |
this.subscriptions.add(atom.commands.add('atom-workspace', { | |
'simple-url-decoder:decode': () => this.decode() | |
})); | |
}, | |
deactivate() { | |
this.subscriptions.dispose(); | |
}, | |
decode() { | |
let editor | |
if (editor = atom.workspace.getActiveTextEditor()) { | |
let text = editor.getText(); | |
// %20 - blank | |
text = text.replace(/%20/g, " "); | |
// %27 - apostrophe | |
text = text.replace(/%27/g, "'"); | |
editor.setText(text) | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Simple URL Decoder
Replace %20 with a blank and %27 with an apostrophe in the whole document in Atom Editor.
This is the main coding file of my plugin, learn how to create your own plugin here.
See my Simple URL Decoder in action here.