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

Generating a site with Swift? #55

Open
mortenjust opened this issue Apr 29, 2020 · 1 comment
Open

Generating a site with Swift? #55

mortenjust opened this issue Apr 29, 2020 · 1 comment

Comments

@mortenjust
Copy link

Hey there - anyone had any luck compressing a site with Swift? I've tried this, but the result is different than if I do it on the command line

let raw : Data! = String("hello world").data(using: .utf8)
let compressed2 = try! (raw as NSData).compressed(using: .lzma)
print("https://itty.bitty.site/#/" + compressed2.base64EncodedString(options: []))

It outputs

https://itty.bitty.site/#//Td6WFoAAAD/EtlBAgAhARYAAAB0L+WjAQAKaGVsbG8gd29ybGQAAAABGws5p2IeBnKeegEAAAAAAFla

But it should be

https://itty.bitty.site/#/XQAAQAD//////////wA0GUnujekXiTozYAX3z2T/+3ggAA==

@mortenjust
Copy link
Author

mortenjust commented Apr 29, 2020

The weird thing is that it works in the other direction

let encoded = "XQAAAAT//////////wA0GUnujekXiTozYAX3z2T/+3ggAA=="
let uncData = try! NSData(base64Encoded: encoded, options: .ignoreUnknownCharacters)!
    .decompressed(using: .lzma)

String(data: uncData as Data, encoding: .utf8) // prints hello world

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

1 participant