Skip to content

Commit afc0df7

Browse files
authored
fix: remove identity prefix from site URL if exists (#482)
1 parent f84b9cb commit afc0df7

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/components/forms/siteurl.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
import { h, Component } from "preact";
22

3+
/**
4+
* @arg {string} string
5+
* @arg {string} ending
6+
**/
7+
function removeFrom(string, mark) {
8+
const index = string.indexOf(mark);
9+
if (index === -1) {
10+
return string;
11+
}
12+
13+
return string.substring(0, string.length - mark.length);
14+
}
15+
316
export default class SiteURLForm extends Component {
417
constructor(props) {
518
super(props);
@@ -12,7 +25,8 @@ export default class SiteURLForm extends Component {
1225

1326
addSiteURL = (e) => {
1427
e.preventDefault();
15-
this.props.onSiteURL(this.state.url);
28+
const url = removeFrom(this.state.url, "/.netlify/identity");
29+
this.props.onSiteURL(url);
1630
};
1731

1832
clearSiteURL = (e) => {

0 commit comments

Comments
 (0)