Skip to content

Commit

Permalink
Revert "pnp#1101: fix issue with adding link by typing in FilePicker …
Browse files Browse the repository at this point in the history
…"From a link" tab"

This reverts commit e2afed6.

Revert "pnp#1101: fix issue with adding link by typing in FilePicker "From a link" tab"

This reverts commit e2afed6.
  • Loading branch information
Ateina committed May 4, 2024
1 parent e2afed6 commit a8e992c
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export default class LinkFilePickerTab extends React.Component<ILinkFilePickerTa
className={styles.linkTextField}
label={strings.LinkFileInstructions}
ariaLabel={strings.LinkFileInstructions}
defaultValue={"https://"}
onGetErrorMessage={(value: string) => this._getErrorMessagePromise(value)}
autoAdjustHeight={false}
underlined={false}
Expand Down Expand Up @@ -63,7 +64,7 @@ export default class LinkFilePickerTab extends React.Component<ILinkFilePickerTa
* Called as user types in a new value
*/
private _handleChange = (fileUrl: string): void => {
const filePickerResult: IFilePickerResult = fileUrl ? {
const filePickerResult: IFilePickerResult = fileUrl && this._isUrl(fileUrl) ? {
fileAbsoluteUrl: fileUrl,
fileName: GeneralHelper.getFileNameFromUrl(fileUrl),
fileNameWithoutExtension: GeneralHelper.getFileNameWithoutExtension(fileUrl),
Expand All @@ -80,15 +81,15 @@ export default class LinkFilePickerTab extends React.Component<ILinkFilePickerTa
*/
private _getErrorMessagePromise = async (value: string): Promise<string> => {
// DOn't give an error for blank or placeholder value, but don't make it a valid entry either
if (value === undefined || value === '') {
if (value === undefined || value === 'https://') {
this.setState({ isValid: false });
return '';
}

// Make sure that user is typing a valid URL format
if (!this._isUrl(value)) {
this.setState({ isValid: false });
return strings.InvalidUrlError;
return '';
}

// If we don't allow external links, verify that we're in the same domain
Expand Down

0 comments on commit a8e992c

Please sign in to comment.