From 622c8a772249a003367b912e99d61b0ea54d437d Mon Sep 17 00:00:00 2001 From: Michael Fix Date: Sun, 9 Feb 2020 10:50:45 -0800 Subject: [PATCH] remove old unsplash photocredit if it is an exact match (#947) --- components/Editor.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/Editor.js b/components/Editor.js index 5842019..beef5fd 100644 --- a/components/Editor.js +++ b/components/Editor.js @@ -42,6 +42,7 @@ const SnippetToolbar = dynamic(() => import('./SnippetToolbar'), { }) const getConfig = omit(['code']) +const unsplashPhotographerCredit = /\n\n\/\/ Photo by.+?on Unsplash/ class Editor extends React.Component { static contextType = ApiContext @@ -292,7 +293,9 @@ class Editor extends React.Component { if (photographer) { this.updateState(({ code = DEFAULT_CODE }) => ({ ...changes, - code: code + `\n\n// Photo by ${photographer.name} on Unsplash`, + code: + code.replace(unsplashPhotographerCredit, '') + + `\n\n// Photo by ${photographer.name} on Unsplash`, preset: null })) } else {