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

Opening custom URL Protocol Handler has description in place of name in Windows Portable #8777

Open
tjcouch-sil opened this issue Jan 17, 2025 · 2 comments

Comments

@tjcouch-sil
Copy link

  • electron-builder version: 25.1.8, 26.0.0-alpha.9
  • Node version: 20.18.0
  • Electron version: 32.1.2
  • Operating System: Windows
  • Target: portable

Full electron-builder.json5 Configuration

Relevant parts of `electron-builder.json5` Configuration

{
  productName: 'Platform.Bible',
  appId: 'org.paranext.PlatformBible',
  copyright: 'Copyright © 2022-2024 SIL Global',
  protocols: {
    name: 'platform-bible',
    schemes: ['platform-bible'],
  },
  asar: true,
  asarUnpack: '**\\*.{node,dll}',
  files: ['dist', 'node_modules', 'package.json'],
  mac: {
    ...
  },
  dmg: {
    ...
  },
  win: {
    target: ['nsis', 'nsis-web', 'portable'],
    extraResources: [
      {
        from: './c-sharp/bin/Release/net8.0/publish/win-x64/',
        to: './dotnet/',
      },
    ],
  },
  linux: {
    ...
  },
  directories: {
    app: 'release/app',
    buildResources: 'assets',
    output: 'release/build',
  },
  extraResources: ['./assets/**', { from: './extensions/dist/', to: './extensions' }],
  publish: {
    provider: 'github',
    owner: 'paranext',
    repo: 'paranext-core',
  },
}

release/app/package.json (The one electron-builder uses as configured by directories.app):

{
  "name": "platform-bible",
  "version": "0.3.0",
  "description": "Extensible Bible translation software",
  "license": "MIT",
  "author": {
    "name": "Platform",
    "url": "https://github.com/paranext/"
  },
  "main": "./dist/main/main.js",
  "scripts": {
    "rebuild": "node -r ts-node/register ../../.erb/scripts/electron-rebuild.js",
    "postinstall": "npm run rebuild && npm run link-modules",
    "link-modules": "node -r ts-node/register ../../.erb/scripts/link-modules.ts"
  },
  "dependencies": {},
  "volta": {
    "extends": "../../package.json"
  }
}

I have registered a custom URL protocol handler following this Electron walkthrough on Deep Links. When I run my application's executable in the win-unpacked folder and navigate to a URL with my registered scheme, Chrome and Firefox ask me if I want to open my application (with the application's name):

chrome showing the right app name

firefox showing the right app name

However, when I run my application's portable build and navigate to a URL with my registered scheme, Chrome and Firefox both asks me if I want to open my application's description:

chrome showing the erroneous app name

firefox showing the erroneous app name

I don't know where these applications are getting the text to display on these pop-ups. Nothing in the Registry's URL-protocol-related keys seems to contain the name or the description, so I imagine it's not getting it from there. I renamed the portable executable to be the exact same name as the win-unpacked executable, but that didn't change anything. I did notice the description in the file metadata is just the name in the win-unpacked version but is the actual description in the portable version:

win-unpacked version:
win-unpacked file details

Portable version:
portable file details

I thought maybe #8599 was possibly related in some way, so I tried electron-builder 26.0.0-alpha.9, but that didn't seem to change anything.

Any ideas? Thank you very much!

@mmaietta
Copy link
Collaborator

So I think this is the code is where the configuration logic occurs:

const icon = `"${installedIconPath}"`
const commandText = `"Open with ${packager.appInfo.productName}"`
const command = '"$appExe $\\"%1$\\""'
registerFileAssociationsScript.insertMacro("APP_ASSOCIATE", `"${ext}" "${item.name || ext}" "${item.description || ""}" ${icon} ${commandText} ${command}`)

Re: the difference between win-unpacked versus portable/installed, I think that's because running from win-unpacked only has the URL protocol handler set during electron runtime, whereas running a portable or installed application has executed the NSIS script files (thus having run the APP_ASSOCIATE macro to register the nsis metadata)

@tjcouch-sil
Copy link
Author

FYI I just tried with the installed version of the application (it went into %localappdata%/Programs), and it seems it says the application name. Not sure how this affects consideration. Thanks for looking into it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants