[fix] View href 'target' string may start with underscore

Close #1969
This commit is contained in:
Charlie Croom
2021-03-30 10:30:12 -04:00
committed by Nicolas Gallagher
parent 0ac406c91e
commit 781a4191f0
2 changed files with 3 additions and 3 deletions
@@ -110,7 +110,7 @@ describe('components/View', () => {
const hrefAttrs = { const hrefAttrs = {
download: 'filename.jpg', download: 'filename.jpg',
rel: 'nofollow', rel: 'nofollow',
target: 'blank' target: '_blank'
}; };
const { container } = render(<View href="https://example.com" hrefAttrs={hrefAttrs} />); const { container } = render(<View href="https://example.com" hrefAttrs={hrefAttrs} />);
expect(container.firstChild).toMatchSnapshot(); expect(container.firstChild).toMatchSnapshot();
+2 -2
View File
@@ -107,8 +107,8 @@ const View = forwardRef<ViewProps, *>((props, forwardedRef) => {
if (rel != null) { if (rel != null) {
supportedProps.rel = rel; supportedProps.rel = rel;
} }
if (typeof target === 'string' && target.charAt(0) !== '_') { if (typeof target === 'string') {
supportedProps.target = '_' + target; supportedProps.target = target.charAt(0) !== '_' ? '_' + target : target;
} }
} }