Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: URL replacer doesn't work #359

Closed
ooker777 opened this issue Aug 12, 2024 · 11 comments
Closed

[Bug]: URL replacer doesn't work #359

ooker777 opened this issue Aug 12, 2024 · 11 comments
Assignees
Labels
❓ Question Further information is requested

Comments

@ooker777
Copy link
Contributor

ooker777 commented Aug 12, 2024

What does the text transformation to the URL mean? In my understanding it just replaces text in the filename. So I expect if you have a file a.md, and with the rule to replace a with b, then you get b.md as the output. But it doesn't work.

Ultimately I want to avoid the % character in the filename to avoid URIError: URI malformed. But even enabling the Encode to URI option it still isn't converted to %25.

v7.2.12

@ooker777 ooker777 added the 🐛 Bug Something isn't working label Aug 12, 2024
@Mara-Li
Copy link
Member

Mara-Li commented Aug 12, 2024

Can't repro, the % is converted into %25 on my side ; and % is replaced using the link replacement.
Note: if you use uri encoding, the regex is applied AFTER the encoding.

@ooker777
Copy link
Contributor Author

That's strange. Can you share your config? Mine is:

{
  "github": {
    "branch": "main",
    "automaticallyMergePR": true,
    "dryRun": {
      "enable": false,
      "folderName": "github-publisher"
    },
    "tokenPath": "%configDir%/plugins/%pluginID%/env",
    "api": {
      "tiersForApi": "Github Free/Pro/Team (default)",
      "hostname": ""
    },
    "workflow": {
      "commitMessage": "[skip netlify] PUBLISHER",
      "name": ""
    },
    "verifiedRepo": true
  },
  "upload": {
    "behavior": "obsidian",
    "defaultName": "docs",
    "rootFolder": "docs",
    "yamlFolderKey": "category",
    "frontmatterTitle": {
      "enable": true,
      "key": "filename"
    },
    "replaceTitle": [],
    "replacePath": [],
    "autoclean": {
      "includeAttachments": true,
      "enable": true,
      "excluded": [
        "docs/assets/favicon.svg",
        "docs/assets/favicon.ico",
        "docs/_data.yaml",
        "docs/_includes/og_image.jsx"
      ]
    },
    "folderNote": {
      "enable": true,
      "rename": "index.md",
      "addTitle": {
        "enable": true,
        "key": "title"
      }
    },
    "metadataExtractorPath": "",
    "subFolder": ""
  },
  "conversion": {
    "hardbreak": false,
    "dataview": true,
    "censorText": [
      {
        "entry": "/\\!\\[.*\\]\\(https:\\/\\/.*(youtube\\.com|youtu\\.be)\\/(.*).*\\)/",
        "replace": "<iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/$2\" title=\"YouTube video player\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen></iframe>",
        "after": true,
        "inCodeBlocks": true
      }
    ],
    "tags": {
      "inline": true,
      "exclude": [],
      "fields": []
    },
    "links": {
      "internal": true,
      "unshared": false,
      "wiki": true,
      "slugify": "disable"
    }
  },
  "embed": {
    "attachments": true,
    "overrideAttachments": [],
    "keySendFile": [
      "image"
    ],
    "notes": true,
    "folder": "docs/assets/attachments",
    "convertEmbedToLinks": "keep",
    "charConvert": "->",
    "unHandledObsidianExt": [],
    "sendSimpleLinks": true,
    "forcePushAttachments": [],
    "useObsidianFolder": false
  },
  "plugin": {
    "shareKey": "share",
    "excludedFolder": [
      "Ξ Thiết lập"
    ],
    "copyLink": {
      "enable": true,
      "links": "https://kiếmtiền.quảcầu.cc/",
      "removePart": [
        "content",
        "index.md"
      ],
      "transform": {
        "toUri": true,
        "slugify": "disable",
        "applyRegex": [
          {
            "regex": "%",
            "replacement": ""
          }
        ]
      }
    },
    "setFrontmatterKey": "Set"
  },
  "tabsId": "plugin-settings"
}

System info:

Obsidian version: v1.6.7
Installer version: v1.4.13
Operating system: Windows 10 Home Single Language 10.0.22631
Login status: logged in
Catalyst license: none
Insider build toggle: off
Live preview: off
Base theme: adapt to system
Community theme: Catppuccin v0.4.18
Snippets enabled: 2
Restricted mode: off
Plugins installed: 1
Plugins enabled: 1
1: Enveloppe v7.2.12

@Mara-Li
Copy link
Member

Mara-Li commented Aug 13, 2024

Why you remplace % by %? ^^'

@ooker777
Copy link
Contributor Author

They are different characters actually: % vs . It's to workaround the escaping character that uses the normal one (%). If you replace that with a and b, the problem persists.

@Mara-Li
Copy link
Member

Mara-Li commented Aug 13, 2024

It works on my side with your configuration…
I tried % to x
And your (strange :p)
image

@ooker777
Copy link
Contributor Author

Hmm, I just realize that those options are only available when Copy link is enable. Does that mean this whole section is just for copying the URL, not actually modifying the output filename? I use a sandbox vault and only install the plugin and import the setting, but in my output repo the filename still isn't converted.

Where do you get that screenshot? It doesn't seem to be from the console.

@Mara-Li
Copy link
Member

Mara-Li commented Aug 13, 2024

I just copy / pasted XD
And Yes, it's only enabled when the copy-link option is enabled! And it doesn't change the name.
To change name, you need to use the filepath option.

It's just a shortcuts to quickly create a link using obsidian with your configuration, without relying on other plugin.

@ooker777
Copy link
Contributor Author

Is the link automatically copied into the clipboard, or do I need to execute a command manually?

Is there a way to automatically replace the file name, like the option to replace the file content?

@Mara-Li
Copy link
Member

Mara-Li commented Aug 15, 2024

  1. It should be, and a command can be added
  2. Yes, in filepath settings.

@ooker777
Copy link
Contributor Author

ooker777 commented Aug 15, 2024

Yes, in filepath settings.

Stupid me 🤦

The link isn't automatically copied into the clipboard to me. There is also no command so I don't know how to copy it.

@Mara-Li
Copy link
Member

Mara-Li commented Aug 15, 2024

For the commands, it needs to be enabled.

The auto-copy (even if the command is disabled) works on my side

@Mara-Li Mara-Li closed this as not planned Won't fix, can't repro, duplicate, stale Aug 16, 2024
@Mara-Li Mara-Li added ❓ Question Further information is requested and removed 🐛 Bug Something isn't working labels Aug 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
❓ Question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants