Jump to content

How to open url without urlencode?


ifvsvg

Recommended Posts

I want to open following url in alfred with "Open URL ",

https://www.youxuan68.com/search.asp?keyword=%u5948%u5B66

but alfred ALWAYS urlencode it, and url become

https://www.youxuan68.com/search.asp?keyword=%25u5948%25u5B66

Which is the WRONG url.

 

I also tried "Run Script Action" with

open "https://www.youxuan68.com/search.asp?keyword=%u5948%u5B66"

but I got 

Unable to interpret 'https://www.youxuan68.com/search.asp?keyword=%u5948%u5B66' as a path or URL

 

 

Who can help me, please.

 

It really make me stuck.

Edited by ifvsvg
add description
Link to comment
1 hour ago, ifvsvg said:

I want to open following url in alfred with "Open URL ",

https://www.youxuan68.com/search.asp?keyword=%u5948%u5B66

 

Alfred is encoding it because that's not a valid URL. You can't get Alfred to open that URL without it encoding the %-signs to make the URL valid, and I don't think macOS will do it either.

 

You need to encode your URLs properly. %uXXXX escaping is not valid.

Edited by deanishe
Link to comment
6 hours ago, deanishe said:

 

Alfred is encoding it because that's not a valid URL. You can't get Alfred to open that URL without it encoding the %-signs to make the URL valid, and I don't think macOS will do it either.

 

You need to encode your URLs properly. %uXXXX escaping is not valid.

 

I can open the URL in Chrome, why you judge the url is not valid?

 

Alfred is more AUTHORITATIVE than Chrome?

 

 

https://www.youxuan68.com/search.asp?keyword=%u5948%u5B66

 

The URL is just here, anyone can tell me how to open it by alfred?

 

Or Alfred is used to refuse customer‘s requirement by fictitious reason?

 

 

Link to comment
21 minutes ago, ifvsvg said:

I can open the URL in Chrome, why you judge the url is not valid?

 

It's not judgement, it's fact. %uXXXX escaping is non-standard. Sure, Chrome may support it, but macOS doesn't.

 

23 minutes ago, ifvsvg said:

Alfred is more AUTHORITATIVE than Chrome?

 

The standards are, and they say your URL is not valid.

 

23 minutes ago, ifvsvg said:

The URL is just here, anyone can tell me how to open it by alfred?

 

I already told you: fix the URL so it's valid.

 

Chrome may accept it if you paste it directly into the browser, but macOS APIs will not accept your URL. Because it's not valid.

Link to comment
1 hour ago, deanishe said:

 

It's not judgement, it's fact. %uXXXX escaping is non-standard. Sure, Chrome may support it, but macOS doesn't.

 

 

The standards are, and they say your URL is not valid.

 

 

I already told you: fix the URL so it's valid.

 

Chrome may accept it if you paste it directly into the browser, but macOS APIs will not accept your URL. Because it's not valid.

 

I am not the developer of that site, I can not change the url.

 

But I pay for alfred.

 

Maybe,

alfred can be compatile to this situation, for his paid user, like chrome?

Edited by ifvsvg
Link to comment
15 minutes ago, ifvsvg said:

alfred can be compatile to this situation, for his paid user, like chrome?

 

If Chrome accepts the URL, then you can pass it directly to Chrome by running:

 

#!/bin/zsh
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome 'https://www.youxuan68.com/search.asp?keyword=%u5948%u5B66'

 

But I don't think it will ever work with Open URL because Apple's libraries simply won't accept that URL. Try the following in an Xcode Swift Playground:

 

import Foundation

let URLs = [
    // test URL
    "https://www.alfredforum.com",
    // your invalid URL
    "https://www.youxuan68.com/search.asp?keyword=%u5948%u5B66",
    // properly URL-encoded
    "https://www.youxuan68.com/search.asp?keyword=%25u5948%25u5B66",
]

for str in URLs {
    if URL(string: str) != nil {
        print("  valid: \(str)")
    } else {
        print("invalid: \(str)")
    }
}

 

Link to comment
27 minutes ago, deanishe said:

 

If Chrome accepts the URL, then you can pass it directly to Chrome by running:

 

#!/bin/zsh
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome 'https://www.youxuan68.com/search.asp?keyword=%u5948%u5B66'

 

But I don't think it will ever work with Open URL because Apple's libraries simply won't accept that URL. Try the following in an Xcode Swift Playground:

 

import Foundation

let URLs = [
    // test URL
    "https://www.alfredforum.com",
    // your invalid URL
    "https://www.youxuan68.com/search.asp?keyword=%u5948%u5B66",
    // properly URL-encoded
    "https://www.youxuan68.com/search.asp?keyword=%25u5948%25u5B66",
]

for str in URLs {
    if URL(string: str) != nil {
        print("  valid: \(str)")
    } else {
        print("invalid: \(str)")
    }
}

 

 

/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome 'https://www.youxuan68.com/search.asp?keyword=%u5948%u5B66'

 

Above command works, although it's not a perfect solution.

 

Thanks!

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...