Greasy Fork is available in English.

Discussions » Development

Match rule to all top-level domains

§
Posted: 12-05-2023
Edited: 12-05-2023

I need a match rule to all possible domains

http://greasyfork.*/search
https://greasyfork.*/search
http://www.greasyfork.*/search
https://www.greasyfork.*/search

The following rules appear not to work:

/^(https?:\/\/)?(www\.)?greasyfork\.[^\/]+\/search/i
/^(https?|http):\/\/(www\.)?greasyfork\.[a-z]{2,}\/search[^\s]*$/i
/https?:\/\/(www\.)?greasyfork\.[a-z]{2,}\/search/

Tested against Proxy Redirect.

NotYouMod
§
Posted: 12-05-2023

There you go:

/^https?:\/\/(www\.)?greasyfork\.[a-z]{2,}\/search/

Here are some tests for you:

const reSearch = /^https?:\/\/(www\.)?greasyfork\.[a-z]{2,}\/search/

// Passing

test('http://greasyfork.org/search')
test('http://greasyfork.com/search')
test('http://greasyfork.net/search')
test('https://greasyfork.org/search')
test('https://greasyfork.com/search')
test('https://greasyfork.net/search')
test('http://www.greasyfork.org/search')
test('http://www.greasyfork.com/search')
test('http://www.greasyfork.net/search')
test('https://www.greasyfork.org/search')
test('https://www.greasyfork.com/search')
test('https://www.greasyfork.net/search')

// Not passing

test('someprotocol://greasyfork.org/search')
test('http://greeeeasyfork.com/search')
test('http://greasydork.net/search')
test('https://greasyfork.org/')
test('https://greasyfork.comsearch/')
test('https://sleazyfork.net/search')
test('http://totallydifferentwebsite.com/search')

function test(url) {
  return console.log(url, '->', reSearch.test(url) ? '✅ Passing!' : '❌ Not Passing!')
}

Post reply

Sign in to post a reply.