Skip to content

Commit

Permalink
fix: Possible null crash
Browse files Browse the repository at this point in the history
  • Loading branch information
HEmile committed Nov 3, 2023
1 parent c549bc7 commit 2fdea76
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "supercharged-links-obsidian",
"name": "Supercharged Links",
"version": "0.11.0",
"version": "0.11.1",
"minAppVersion": "1.4.0",
"description": "Add properties and menu options to links and style them!",
"author": "mdelobelle & Emile",
Expand Down
2 changes: 1 addition & 1 deletion src/linkAttributes/linkAttributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function setLinkNewProps(link: HTMLElement, new_props: Record<string, string>) {
// Only update if value is different
if (!newValue || curValue != newValue) {
link.setAttribute("data-link-" + key, new_props[key])
if (new_props[key].startsWith && new_props[key].startsWith('http')) {
if (new_props[key]?.startsWith && new_props[key].startsWith('http')) {
link.style.setProperty(`--data-link-${key}`, `url(${new_props[key]})`);
} else {
link.style.setProperty(`--data-link-${key}`, new_props[key]);
Expand Down
2 changes: 1 addition & 1 deletion src/linkAttributes/livePreview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function buildCMViewPlugin(app: App, _settings: SuperchargedLinksSettings
headerEl.setAttrs(this.attributes);
for (let key in this.attributes) {
// CSS doesn't allow interpolation of variables for URLs, so do it beforehand to be nice.
if (this.attributes[key].startsWith && this.attributes[key].startsWith('http')) {
if (this.attributes[key]?.startsWith && this.attributes[key].startsWith('http')) {
headerEl.style.setProperty(`--${key}`, `url(${this.attributes[key]})`);
} else {
headerEl.style.setProperty(`--${key}`, this.attributes[key]);
Expand Down

0 comments on commit 2fdea76

Please sign in to comment.