Skip to content

Commit

Permalink
upgrade std from 0.200.0 to 0.217.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Sloaix committed Feb 25, 2024
1 parent 4803477 commit 3d8f116
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
4 changes: 2 additions & 2 deletions deno.jsonc
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"imports": {
"std/": "https://deno.land/std@0.200.0/"
"std/": "https://deno.land/std@0.217.0/"
},
"tasks": {
"test": "deno test -A --unstable"
"test": "deno test -A --unstable-net"
},
"test": {
"include": [
Expand Down
14 changes: 12 additions & 2 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions src/magnet.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { decode as base32Decode } from 'std/encoding/base32.ts'
import { decode as hexDecode } from 'std/encoding/hex.ts'
import { decodeBase32 } from 'std/encoding/base32.ts'
import { decodeHex } from 'std/encoding/hex.ts'

const PREFIX = 'magnet:?xt=urn:'
const PREFIX_BITTORRENT_INFO_HASH = `${PREFIX}btih:`
const PREFIX_SHA1 = `${PREFIX}sha1:`
const PREFIX_LSIT = [PREFIX_BITTORRENT_INFO_HASH, PREFIX_SHA1]
const textEncoder = new TextEncoder()

// check is valid magnet for bittorent
export function isValid(magnet: string) {
Expand Down Expand Up @@ -72,11 +71,11 @@ function parseNSS(nss: string) {

// if is hex sha1
if (isSha1Hex(hashString)) {
hash = hexDecode(textEncoder.encode(hashString))
hash = decodeHex(hashString)
}
// if is base32 sha1
else if (isSha1Base32(hashString)) {
hash = base32Decode(hashString)
hash = decodeBase32(hashString)
}

if (!hash) {
Expand Down

0 comments on commit 3d8f116

Please sign in to comment.