Greasy Fork is available in English.

게시판 » 개발

Match rule to all top-level domains

§
작성: 2023-05-12
수정: 2023-05-12

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.

NotYou관리자
§
작성: 2023-05-12

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!')
}

댓글 남기기

댓글을 남기려면 로그인하세요.