Skip to content

Commit

Permalink
fix: remove identity prefix from site URL if exists (#482)
Browse files Browse the repository at this point in the history
  • Loading branch information
erezrokah authored Jul 26, 2021
1 parent f84b9cb commit afc0df7
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/components/forms/siteurl.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
import { h, Component } from "preact";

/**
* @arg {string} string
* @arg {string} ending
**/
function removeFrom(string, mark) {
const index = string.indexOf(mark);
if (index === -1) {
return string;
}

return string.substring(0, string.length - mark.length);
}

export default class SiteURLForm extends Component {
constructor(props) {
super(props);
Expand All @@ -12,7 +25,8 @@ export default class SiteURLForm extends Component {

addSiteURL = (e) => {
e.preventDefault();
this.props.onSiteURL(this.state.url);
const url = removeFrom(this.state.url, "/.netlify/identity");
this.props.onSiteURL(url);
};

clearSiteURL = (e) => {
Expand Down

0 comments on commit afc0df7

Please sign in to comment.