Skip to content

Commit c74655e

Browse files
committed
[E] Use href as to for internal links
1 parent a473c6a commit c74655e

File tree

1 file changed

+6
-16
lines changed
  • client/src/reader/components/section/body-nodes/nodes

1 file changed

+6
-16
lines changed

client/src/reader/components/section/body-nodes/nodes/Link.js

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React, { Component } from "react";
22
import PropTypes from "prop-types";
33
import { Link } from "react-router-dom";
4-
import config from "config";
54
import validatedNode from "../higher-order/ValidatedNode";
65

76
class LinkNode extends Component {
@@ -38,20 +37,6 @@ class LinkNode extends Component {
3837
}
3938
}
4039

41-
adjustedAttributes() {
42-
if (this.href.startsWith("#"))
43-
return { ...this.props.attributes, to: this.props.attributes.href };
44-
45-
const parsedURI = new URL(this.href, config.services.client.url);
46-
const { pathname, search: query, hash } = parsedURI;
47-
const adjustedAttributes = { to: { pathname, query } };
48-
if (hash) {
49-
adjustedAttributes.to.hash = hash;
50-
}
51-
delete Object.assign(adjustedAttributes, this.props.attributes).href;
52-
return adjustedAttributes;
53-
}
54-
5540
renderChildren() {
5641
return React.Children.map(this.props.children, child => {
5742
if (React.isValidElement(child)) {
@@ -76,7 +61,12 @@ class LinkNode extends Component {
7661
);
7762
}
7863

79-
return <Link {...this.adjustedAttributes()}>{this.renderChildren()}</Link>;
64+
const { href, ...attrs } = this.props.attributes;
65+
return (
66+
<Link {...attrs} to={href}>
67+
{this.renderChildren()}
68+
</Link>
69+
);
8070
}
8171
}
8272

0 commit comments

Comments
 (0)