Skip to content

Instantly share code, notes, and snippets.

@denisenepraunig
Last active March 15, 2017 20:15
Show Gist options
  • Save denisenepraunig/d831fa7bdab4b486c3a2dfe2393309dc to your computer and use it in GitHub Desktop.
Save denisenepraunig/d831fa7bdab4b486c3a2dfe2393309dc to your computer and use it in GitHub Desktop.
decode URLs - %20 and %27
'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)
}
}
};
@denisenepraunig
Copy link
Author

denisenepraunig commented Mar 15, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment