ssbc / ssb-ref

check if a string is a valid ssb-reference
MIT License
14 stars 10 forks source link

add .extract() #7

Closed pfrazee closed 8 years ago

pfrazee commented 8 years ago

Adds a function for extracting an ssb-ref out of a URL. From the readme:

//extract a ref out of a url
ref.extract('http://localhost:7777/#/msg/%pGzeEydYdHjKW1iIchR0Yumydsr3QSp8+FuYcwVwi8Q=.sha256?foo=bar')
 == '%pGzeEydYdHjKW1iIchR0Yumydsr3QSp8+FuYcwVwi8Q=.sha256'
//url-encoding is supported
ref.extract('http://localhost:7777/#/msg/%25pGzeEydYdHjKW1iIchR0Yumydsr3QSp8%2BFuYcwVwi8Q%3D.sha256?foo=bar')
 == '%pGzeEydYdHjKW1iIchR0Yumydsr3QSp8+FuYcwVwi8Q=.sha256' 
pfrazee commented 8 years ago

@dominictarr good to merge? This is used in patchwork's hosted branch to deal with a user copy-pasting a URL that contains an ssb ref. See https://github.com/ssbc/patchwork/pull/231

dominictarr commented 8 years ago

:+1:

pfrazee commented 8 years ago

Going to publish as 2.3.0, just need https://github.com/miguelmota/is-valid-domain/pull/2 to merge so that npm ls stops failing when I try to publish.

pfrazee commented 8 years ago

@dominictarr hey can you add me as a collaborator to this npm repo?

pfrazee commented 8 years ago

published 2.3.0