Skip to content

Commit

Permalink
fix uri-encode
Browse files Browse the repository at this point in the history
  • Loading branch information
rb-x committed Jan 21, 2023
1 parent ab5c05c commit a71c62a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/components/encoding/URLEncode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useState } from 'react';
import { Button, Input, Typography, message, Divider } from 'antd';
import { CopyOutlined, createFromIconfontCN, ClearOutlined } from '@ant-design/icons';
import Clipboard from 'react-clipboard.js';
import { escape, unescape } from 'querystring';

const { Title, Paragraph } = Typography;
const IconFont = createFromIconfontCN( {
Expand All @@ -20,10 +21,10 @@ const Base64Encode = () => {
};
const handleClick = ( type: string ) => {
if ( type === 'encode' ) {
setOutput( encodeURI( input ) );
setOutput( escape( input ) );
} else if ( type === 'decode' ) {
try {
setOutput( decodeURI( input ) );
setOutput( unescape( input ) );
} catch ( ex ) {
setOutput( 'Unable to decode properly : Incorrect base64 :-( ' );
message.error( 'Incorrect Base64 please try something else' );
Expand Down

0 comments on commit a71c62a

Please sign in to comment.