Skip to content

Commit

Permalink
Try prevent relative links if URL isn't fully typed out (#5917)
Browse files Browse the repository at this point in the history
* Try to prevent relative links if URL isn't fully typed out

* Refactoring: move correctLink function to utils folder

* Update to use prependHTTP function by @wordpres/url package

* Remove correctLink function

* Framework: Update package-lock.json for url@1.1.0
  • Loading branch information
Rahmon authored and aduth committed Apr 30, 2018
1 parent 424dab7 commit f037e90
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion blocks/rich-text/format-toolbar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
withSpokenMessages,
} from '@wordpress/components';
import { keycodes } from '@wordpress/utils';
import { prependHTTP } from '@wordpress/url';

/**
* Internal dependencies
Expand Down Expand Up @@ -138,7 +139,7 @@ class FormatToolbar extends Component {
event.preventDefault();
this.setState( { isEditingLink: false, isAddingLink: false, newLinkValue: '' } );
this.props.onChange( { link: {
value: this.state.newLinkValue,
value: prependHTTP( this.state.newLinkValue ),
target: this.state.opensInNewWindow ? '_blank' : null,
rel: this.state.opensInNewWindow ? 'noreferrer noopener' : null,
} } );
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@wordpress/dom-ready": "1.0.4",
"@wordpress/hooks": "1.1.6",
"@wordpress/i18n": "1.1.0",
"@wordpress/url": "1.0.3",
"@wordpress/url": "1.1.0",
"@wordpress/wordcount": "1.0.0",
"classnames": "2.2.5",
"clipboard": "1.7.1",
Expand Down

0 comments on commit f037e90

Please sign in to comment.